Sometimes, we want to set volume of audio element with JavaScript.
In this article, we’ll look at how to set volume of audio element with JavaScript.
How to set volume of audio element with JavaScript?
To set volume of audio element with JavaScript, we set its volume property.
For instance, we write
const audio = new Audio("test.wav");
audio.volume = 0.2;
to create an Audio object.
Then we set its volume property to set the volume level.
Conclusion
To set volume of audio element with JavaScript, we set its volume property.