html+JQ mp3 音乐播放和暂停代码示例代码
<!DOCTYPE html> <html> <body> <audio id="myAudio" autoplay controls loop> <source src="/i/horse.ogg" type="audio/ogg"> <source src="/i/horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio> <p id="demo"></p> <button onclick="myFunction()">切换</button> <script> function myFunction() { var audio = document.getElementById("myAudio"); if(audio.paused){ audio.play(); }else{ audio.pause(); } } </script> </body> </html>