html5 audio JavaScript 点击播放暂停

var audio = document.getElementById("media");
var btn = document.getElementById("audio");
btn.onclick = function () {
    if (audio.paused) { //判断当前的状态是否为暂停,若是则点击播放,否则暂停
         audio.play();
     }else{
                 audio.pause();
     }
}

猜你喜欢

转载自www.cnblogs.com/duxingdexin/p/9139208.html