Tutorials References Exercises Sign Up Menu
Create Website Get Certified Pro

HTML Audio/Video DOM volumechange Event

❮ HTML Audio/Video DOM Reference


Alert that the volume of a video has been changed:

var vid = document.getElementById("myVideo");
vid.onvolumechange = function() {
    alert("The volume has been changed!");
Try it Yourself »

More "Try it Yourself" examples below.

Definition and Usage

The volumechange event occurs each time the volume of a video/audio has been changed.

This event is invoked by:

  • Increasing or decreasing the volume
  • Muting or unmuting the media player

Tip: Use the volume property of the Audio/Video Object to set or return the audio volume of an audio/video.

Browser Support

The numbers in the table specify the first browser version that fully supports the event.

volumechange Yes 9.0 Yes Yes Yes



<audio|video onvolumechange="myScript">Try it

In JavaScript:

audio|video.onvolumechange=function(){myScript};Try it

In JavaScript, using the addEventListener() method:

audio|video.addEventListener("volumechange", myScript);Try it

Technical Details

Supported HTML tags: <audio> and <video>
Supported JavaScript objects: Audio, Video

More Examples


Alert that the volume of an audio file has been change:

var aud = document.getElementById("myAudio");
aud.onvolumechange = function() {
    alert("The volume has been changed!");
Try it Yourself »

❮ HTML Audio/Video DOM Reference