编辑下面的代码:【加编码】
<html> <body> <audio id="myAudio" controls> <source src="/demo/horse.ogg" type="audio/ogg"> <source src="/demo/horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </source></source></audio><br> <button onclick="enableLoop()" type="button">允许循环播放</button> <button onclick="disableLoop()" type="button">禁止循环播放</button> <button onclick="checkLoop()" type="button">检查循环状态</button> <script> var x = document.getElementById("myAudio"); function enableLoop() { x.loop = true; x.load(); } function disableLoop() { x.loop = false; x.load(); } function checkLoop() { alert(x.loop); } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂