http://codepen.io/hennysmafter/pen/aNrVKG?editors=1010
The code in question is this:
(function($) {
$(document).ready(function(){
$('video').each(function() {
$(this).get(0).pause();
});
});
$(document).on('click','span',function(){
if ( $('li').hasClass('current') ) {
$('li.current').find('video').each(function() {
$(this).get(0).play();
});
} else if ( !$('li').hasClass('current') ) {
$('li').find('video').each(function() {
$(this).get(0).pause();
});
}
});
})(jQuery);
The problem.
The moment the user clicks on the 3rd nav button the li element has not yet assigned the custom class to it. So it now requires the user to manually click a 2nd time on the same nav button(which clearly is stupid.).
Requirements
The li with video elements can be any slide so I can't hardcode it in.
What have I tried.
I have tried Ayyoub Dahhane suggestion which works brilliantly but at the moment it is hardcoded which slides are video slides and this cannot be. I have tried some other codes that can be seen at: http://codepen.io/hennysmafter/pen/PNvEPN & http://codepen.io/hennysmafter/pen/MydEBw I tried working with a delay. Codepen is already changed so no link for this. But it did not work anyway.
I find it absolutely bonkers that this proves to be so freaking difficult. So here my latest attempt which is working but shows a couple of errors in the console and it still requires double clicking: http://codepen.io/hennysmafter/pen/aNrVKG?editors=1010
So back to the drawing board.