W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>本例使用 HTML DOM 将 "onended" 事件分配给 audio 元素。</p> <p>请按播放按钮并等待音频结束。</p> <audio id="myAudio" controls> <source src="/i/horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio> <p id="demo"></p> <script> document.getElementById("myAudio").onended = function() {myFunction()}; function myFunction() { document.getElementById("demo").innerHTML = "The audio has ended."; } </script> </body> </html>