I’m trying to get a ‘video pausing’ bit of js to work on my site. Bit odd – when I add it to the ‘header.php’ it doesn’t work, though I can see it on the page. Works fine when I add it inline in a ‘code block’
<script>
jQuery(document).ready(function ($) {
"use strict";
/* activate pause for lightbulb video if scrolled out of viewport */
$(window).scroll(function() {
$('video').each(function(){
if ($(this).is(":in-viewport( 400 )")) {
$(this)[0].play();
} else {
$(this)[0].pause();
}
});
});
});
</script>
Any ideas why?
Hey,
JS code is not usually added to the header, it is better to place it either in the main content or the footer.
Best regards,
Josue
Ah OK – thanks for letting me know!