Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting property volume of HTML5 audio with jQuery not working

Tags:

html

jquery

audio

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?

like image 776
user1386906 Avatar asked Dec 29 '12 21:12

user1386906


1 Answers

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);
like image 61
Jason Whitted Avatar answered Oct 12 '22 01:10

Jason Whitted