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:
$('.audio').prop(volume, 0.1);
But i got Uncaught Reference Error: volume is not defined
What is wrong with my code?
In your line:
$('.audio').prop(volume, 0.1);
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:
$('.audio').prop("volume", 0.1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With