HTML onvolumechange Event Attribute

Description

The event attribute onvolumechange occurs every time the sound volume value changes (including the complete mute).

Syntax

<element onvolumechange="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE HTML>
<html>
<body>

<p id="demo">Change the sound of audio.</p>

<audio id="myAudio" controls onvolumechange="myFunction()">  
  <source src="audio.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>

<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "You changed the sound";
}
</script> 

<p>
This example shows how to use the onvolumechange attribute for an AUDIO element.</p>

</body>
</html>

Supported Tags

<audio> and <video>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
XXYes3.5XX
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4XXX