I am trying to set the volume of an audio element with jQuery.
<audio class="audio" autoplay="autoplay" controls="controls" src="All_Right.mp3"></audio>
So i am selecting the audio tag and setting the volume like so:
But i got Uncaught Reference Error:
volume is not defined
What is wrong with my code?
In your line:
You are passing
volume as a variable not as a string. You do not have a variable named
volume, which is why you are receiving the error about it not being defined. Try changing it to:
Try with this code:
$('.audio').volume = 0.1;