Skip to content
Related Articles

Related Articles

Improve Article
HTML onended Event Attribute
  • Last Updated : 07 Aug, 2020

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:




<!DOCTYPE html> 
<html
  
<body
    <center
        <h1 style="color:green">GeeksfroGeeks</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
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera
My Personal Notes arrow_drop_up
Recommended Articles
Page :