在JQuery/Javascript中使用暂停/播放图标实现背景音乐
你好,先谢谢你。我非常熟悉JQuery/Javascript,不确定如何用暂停/播放图标实现嵌入式背景音乐。任何帮助都将不胜感激。提前谢谢在JQuery/Javascript中使用暂停/播放图标实现背景音乐,javascript,jquery,Javascript,Jquery,你好,先谢谢你。我非常熟悉JQuery/Javascript,不确定如何用暂停/播放图标实现嵌入式背景音乐。任何帮助都将不胜感激。提前谢谢 <div id="toggle" class="play" style="width: 314px; height: 311px"></div> <script type="text/javascript"></script> $(document).ready(fu
<div id="toggle" class="play" style="width: 314px; height: 311px"></div>
<script type="text/javascript"></script>
$(document).ready(function() {
$('#music').attr("class", "false");
$('#toggle').bind("click", function() {
if ($(this).attr("class") == "play")
$(this).attr("class", "pause");
else
$(this).attr("class", "play");
});
});
$(文档).ready(函数(){
$(#music').attr(“class”,“false”);
$('#toggle')。绑定(“单击”,函数(){
如果($(this.attr(“类”)=“播放”)
$(this.attr(“class”,“pause”);
其他的
$(this.attr(“class”,“play”);
});
});
声音被放置在一个空音域中
当脚本启动时,JavaScript将一个嵌入标记放置在一个空的span标记中。因此,您需要在HTML页面主体的某个位置添加以下span文件,最好在文档顶部附近添加:
<span id="dummy"></span>
Call the Script with an onmouseover or onclick Attribute
使用onmouseover或onclick属性调用脚本
最后需要添加的是一个元素,您希望在单击或鼠标悬停时生成声音。使用以下属性之一调用脚本:
<a href="#" onclick="playSound('URL to soundfile');">Click here to hear a sound</a>
<p onmouseover="playSound('URL to soundfile');">Mouse over this text to hear a sound</p>
将鼠标悬停在此文本上以听到声音
声音被放置在一个空音域中
当脚本启动时,JavaScript将一个嵌入标记放置在一个空的span标记中。因此,您需要在HTML页面主体的某个位置添加以下span文件,最好在文档顶部附近添加:
<span id="dummy"></span>
Call the Script with an onmouseover or onclick Attribute
使用onmouseover或onclick属性调用脚本
最后需要添加的是一个元素,您希望在单击或鼠标悬停时生成声音。使用以下属性之一调用脚本:
<a href="#" onclick="playSound('URL to soundfile');">Click here to hear a sound</a>
<p onmouseover="playSound('URL to soundfile');">Mouse over this text to hear a sound</p>
将鼠标悬停在此文本上以听到声音
您的代码实际上是这样的吗?在什么地方也有收场跳水吗?你看到了什么样的行为?哦,欢迎来到Stackoverflow。JS包含在一个单独的文件中,我从我的网页中提取了html。我主要想问的是,如何用jquery代码关闭背景音乐?谢谢你!比如,当播放图标显示时,我如何让音乐播放,反之亦然?这是您的代码的实际外观吗?在什么地方也有收场跳水吗?你看到了什么样的行为?哦,欢迎来到Stackoverflow。JS包含在一个单独的文件中,我从我的网页中提取了html。我主要想问的是,如何用jquery代码关闭背景音乐?谢谢你!比如,当播放图标显示时,如何播放音乐,反之亦然?