This example demonstrates how to assign an "onended" event to an audio element.
Press play and wait for the audio to end.
<!DOCTYPE html> <html> <body> <audio controls onended="myFunction()"> <source src="sound.ogg" type="audio/ogg"> <source src="sound.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>/* w ww. j a v a 2 s .c om*/ <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = "The video has ended"; } </script> </body> </html>
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <audio> and <video> |