Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change Video Volume via jquery

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading