HTML5播放暂停音乐

查看效果:http://hovertree.com/code/jquery/ueyf7gn4.htm

代码如下:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>jQuery播放音乐 - 何问起</title><base target=_blank />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta charset="utf-8" />
<link rel="stylesheet" href="http://hovertree.com/ziyuan/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
   <div class="playHovertree btn btn-primary">播放</div>
<div class="pauseHovertree btn btn-primary">暂停</div>
<script src="http://hovertree.com/ziyuan/jquery/jquery-2.2.0.min.js"></script>

<script>
    $(document).ready(function() {
        var audioElementHovertree = document.createElement('audio');
        audioElementHovertree.setAttribute('src', 'http://cms.hovertree.com/hovertreesound/hovertreesnow.mp3');
        audioElementHovertree.setAttribute('autoplay', 'autoplay'); //打开自动播放
        //audioElement.load()
 
        $.get();
 
        audioElementHovertree.addEventListener("load", function() {
            audioElementHovertree.play();
        }, true);
 
        $('.playHover'+'tree').click(function() {
            audioElementHovertree.play();
        });
 
        $('.pauseH'+'overtree').click(function() {
            audioElementHovertree.pause();
        });
    });</script>
    <br /><br />
    By <a href="http://hovertree.com">何问起</a> <a href="http://hovertree.com/code/">代码</a>
</body>
</html>

更多特效:http://www.cnblogs.com/roucheng/p/texiao.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值