html5 video with jquery and inview - how to point to the right video element

0 votes

I use the jquery inview plugin top automatically play videos when in view. Since I cannot use IDs for the video I use html5 <video> as selector and all videos are always starting to play. How can I point the play/pause trigger only to the one element that is currently triggering the event and ignore all the others?

$('.video-autoplay').on('inview', function(event, isInView) {
  if (isInView) {
    $('video').trigger('play');
  } else {
    $('video').trigger('pause');
  }
});

many thanks, C

Aug 5, 2022 in Web Development by gaurav
• 23,260 points
1,955 views

1 answer to this question.

0 votes

You can make use of this. For more information, see this answer.

$('.video-autoplay').on('inview', function(event, isInView) {
  if (isInView) {
    $(this).trigger('play');
  } else {
    $(this).trigger('pause');
  }
});
answered Aug 5, 2022 by rajatha
• 7,680 points

Related Questions In Web Development

0 votes
0 answers

How to update HTML element with jQuery and Galleria?

I am using Galleria for a slideshow. ...READ MORE

Aug 11, 2022 in Web Development by gaurav
• 23,260 points
896 views
0 votes
0 answers

how to spin and stop wheel has custom position with jquery

this i my code. I am using this ...READ MORE

Jul 27, 2022 in Web Development by gaurav
• 23,260 points
1,641 views
0 votes
0 answers
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 2,971 views
0 votes
1 answer

How to use jquery with asp.net ajax?

If you weren't aware, Microsoft is planning ...READ MORE

answered Oct 15, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
747 views
0 votes
1 answer

Is 'sparkline' a method?

I suggest you to check 2 things That jquery.sparkline.js is actually ...READ MORE

answered Nov 9, 2018 in Apache Spark by Frankie
• 9,830 points
1,270 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,317 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19, 2020 in PHP by Niroj
• 82,840 points
1,087 views
0 votes
1 answer

How to set jQuery draggable min/max-left and min/max-right

How to set jQuery draggable min/max-left and ...READ MORE

answered Jul 25, 2022 in Web Development by rajatha
• 7,680 points
667 views
0 votes
1 answer

How to set jQuery draggable min/max-left and min/max-right

How to set jQuery draggable min/max-left and ...READ MORE

answered Jul 25, 2022 in Web Development by rajatha
• 7,680 points
1,166 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP