0

I've searched for it, but I just getting more confused.

I want to use this script to show a menubar after scrolling down 200px: https://redvinestudio.com/how-to-make-a-menu-fade-in-on-scroll-using-jquery/

I set the CSS witch is self explained - to put in the custom.css

Than I put this in the functions.php (I'm using a child theme):

function add_latest_jquery() {
   if ( !is_admin() ) {
      wp_deregister_script('jquery');
      wp_register_script('jquery', 'http://code.jquery.com/jquery-latest.js', false);
      wp_enqueue_script('jquery');
   }
}
add_action('wp_print_scripts ', 'add_latest_jquery');

I'm not sure if that's right, because of the !is_admin()

And I just don't know where and how to put the following:

<script type="text/javascript">
(function($) {          
    $(document).ready(function(){                    
        $(window).scroll(function(){                          
            if ($(this).scrollTop() > 200) {
                $('#menu').fadeIn(500);
            } else {
                $('#menu').fadeOut(500);
            }
        });
    });
})(jQuery);
</script>

Thanks!

0

Oh okay.. I think I solved it.

I put the script in the header.php (I think "into the loop" as they say?) just behind the opening <header>-tag:

<body>
<header>
<script type="text/javascript">
(function($) {          
    $(document).ready(function(){                    
        $(window).scroll(function(){                          
            if ($(this).scrollTop() > 200) {
                $('#menu').fadeIn(500);
            } else {
                $('#menu').fadeOut(500);
            }
        });
    });
})(jQuery);
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.