HTML onended Attribute

❮ HTML Attributes


//Accessing the element
var vid = document.getElementById("myVideo");

//Creating a function
vid.onended = function() {
    alert("The video has been ended");


The ended event run when the current playlist is ended.

Standard Syntax

<element onended="script">

Browser Support


Applies to:

The onended attribute can be used on the following element:

Element Attribute
<audio> onended
<video> onended

Attribute Values

Value Description
script Specifies the script to be run on onended.
❮ HTML Attributes