你能帮我这个代码吗?我正在创建一个音频播放器,这是我的代码:
$(document).ready(function () {
$("#play").bind("click", function () {
$("#audio-player")[0].play();
$(this).attr('id', 'pause-bt');
})
$("#pause-bt").live({
click: function () {
$("#audio-player")[0].pause();
$(this).attr('id', 'play');
}
})
})
我正在使用 jquery live 和 bind,但它们都不起作用。
请帮我。
谢谢
最佳答案
感谢奥马尔:https://stackoverflow.com/users/1771795/omar
奥马尔解决的代码
<script type="text/javascript">
$(document).ready(function () {
$(document).on("click", '#play', function () { $("#audio-player")[0].play(); $(this).attr('id', 'pause-bt'); });
$(document).on('click', '#pause-bt', function () { $("#audio-player")[0].pause(); $(this).attr('id', 'play'); });
});
</script>
问题解决了...
关于jquery - HTML5 音频播放器 : Pause not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18760851/