Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #624971

    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?

    #625172

    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

    #625207

    Ah OK – thanks for letting me know!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Adding JS to header’ is closed to new replies.