【html部分】
<div class="book_audio">
<audio id="music" src="img/play.mp3" loop="loop"></audio>
<a id="audio_btn"><img src="img/play.png" width="186" height="185" id="music_btn" border="0"></a>
</div>
【js部分】
$("#audio_btn").click(function(){
var music = document.getElementById("music");
if(music.paused){
music.play();
$("#music_btn").attr("src","img/pause.png");
}else{
music.pause();
$("#music_btn").attr("src","img/play.png");
}
});
网友评论