Home > Mobile >  Change Video Volume via jquery
Change Video Volume via jquery

Time:10-20

I want to change the volume of a video using jQuery. So far it's not working. The trigger('play') works. Is it a problem because the element has no id?

jQuery('.v1 .wpb_single_image').click(function() {
  jQuery(this).addClass(".v1 open-video"); //add the class to the clicked element
  jQuery(".v1 video").trigger('play');
  jQuery(".v1 video").volume = 1.0;
});

If but by nice if somebody can help me out.

CodePudding user response:

volume is a property of the video Element, not of a jQuery object. Therefore you need to use the prop() method:

$(".v1 video").prop('volume', 1.0);

Alternatively you can access the video Element directly:

$(".v1 video").get(0).volume = 1.0;
  • Related