运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>HTML DOM Events</h1> <h2>The onended Event</h2> <p>Use the HTML DOM to assign an "onended" event to an audio element.</p> <p>Press play and wait for the audio to end.</p> <audio id="myAudio" controls> <source src="horse.ogg" type="audio/ogg"> <source src="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>