0

Possible Duplicate:
Using jQuery to control HTML5 <audio> volume

I have a html audio tag:

<audio class="audio" autoplay="autoplay" controls="controls" src="All_Right.mp3"></audio>

If it try to set the volume with Javascript like so:

$('.audio').volume = 0.1;

alert($('.audio').volume);

but that doesn't work.

Community
  • 1
  • 1
user1386906
  • 1,161
  • 6
  • 26
  • 53

1 Answers1

7

I assume you're using jQuery.

$('.audio') returns a jQuery object, not a DOM element.
Setting a property on a jQuery object has no effect on the DOM.

Instead, you need to call the jQuery .prop(name, value) method.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964