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 in Web Development by gaurav
• 17,580 points
11 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 by rajatha
• 7,040 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

3 days ago in Web Development by gaurav
• 17,580 points
7 views
0 votes
0 answers

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

I made a copy of JSbin for ...READ MORE

Jul 20 in Web Development by gaurav
• 17,580 points
9 views
0 votes
0 answers

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

I made a copy of JSbin for ...READ MORE

Jul 21 in Web Development by gaurav
• 17,580 points
16 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 in Web Development by gaurav
• 17,580 points
9 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
190 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
601 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,500 points
308 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,740 points
283 views
0 votes
1 answer

How to use JQuery with ReactJS

Yes, we can use jQuery in ReactJs. ...READ MORE

answered Jun 22 in Web Development by rajatha
• 7,040 points
16 views
0 votes
1 answer

How to hide a div with jQuery?

We hide the divs by adding a CSS ...READ MORE

answered Jun 27 in Web Development by rajatha
• 7,040 points
22 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP