To make it easier to understand please take a look at the Codepen: http://codepen.io/hennysmafter/pen/YqmLKR
The codepen is a simpler version of the actual code with only the parts that are necessary!
In the codepen you have two popups one popup has a video element with autoplay and the other has a video element without autoplay
On document ready all video elements on the page are paused this cannot be changed because of other videos in the actual code
Now I just need to have the code adapted so that:
- On click popup opens and class is added
opened
(already there) - If video element inside popup has autoplay then play the video (not working)
Or no autoplay so do nothing
if ($('.modal-box.opened').find('video').attr(autoplay) == true) { $('.modal-box.opened').find('video').each(function() { $(this).get(0).play(); }); }