Skip to content
Related Articles

Related Articles

HTML onended Event Attribute

View Discussion
Improve Article
Save Article
  • Last Updated : 07 Sep, 2022
View Discussion
Improve Article
Save Article

The HTML onended Attribute is a event attribute which works when the audio/video is ended. We can add some custom message in this event like “Thank for watching”, “Share”, etc. 

Usage: This attribute is used in <audio> and <video> element.

Syntax:

<element onended="myScript">
  • Attribute Value: This attribute contains single value script which works when onended event attribute call.

Example:

HTML




<!DOCTYPE html>
<html>
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h2>HTML onended Event Attribute</h2>
        <audio controls onended="gfgFun()">
            <source src="beep.mp3" type="audio/mpeg">
        </audio>
 
        <script>
            function gfgFun() {
                alert("Thanks for listning");
            }
        </script>
    </center>
</body>
</html>

Output:

 

Supported Browsers:

  • Google Chrome 3
  • Edge 12
  • Internet Explorer 9
  • Firefox 3.5
  • Apple Safari 3.1
  • Opera 10.5
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!