HTML5播放暂停音乐

查看效果:http://hovertree.com/code/jquery/ueyf7gn4.htm代码如下:更多特效:http://www.cnblogs.com/roucheng/p/texi

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

全栈程序员社区此处内容已经被作者隐藏,请输入验证码查看内容
验证码:
请关注本站微信公众号,回复“验证码”,获取验证码。在微信里搜索“全栈程序员社区”或者“www_javaforall_cn”或者微信扫描右侧二维码都可以关注本站微信公众号。

查看效果: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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/120646.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号