HTML onplay Event Attribute
Example
Alert that the video has started to play:
<script>
function myFunction() {
alert('The video has started
to play');
}
</script>
<video onplay="myFunction()">
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The play event occurs when the audio/video has been started or is no longer paused.
Tip: The pause event occurs when the audio/video has been paused.
Browser Support
The numbers in the table specify the first browser version that fully supports the event.
Event | |||||
---|---|---|---|---|---|
play | Yes | 9.0 | Yes | Yes | Yes |
Syntax
<element onplay="script">
Attribute Values
Value | Description |
---|---|
script | The script to be run when the video has started |
Technical Details
Supported HTML tags: | <audio> and <video> |
---|
More Examples
Example
Alert that the audio has started to play:
<script>
function myFunction() {
alert('The audio has started
to play');
}
</script>
<audio onplay="myFunction()">
Try it Yourself »
❮ HTML Audio/Video DOM Reference