[ACCEPTED]-How to add css style if user scroll page over 112px-scrolltop

Accepted answer
Score: 11

Try using below code

<script type="text/javascript">
$(window).scroll(function(){ 

var a = 112;
var pos = $(window).scrollTop();
if(pos > a) {
    $("menu").css({
                position: 'fixed'
            });
}
else {
    $("menu").css({
                position: 'absolute',
                top:'600px'
            });
}
});
</script>
  • $window.scrollTop changed to $(window).scroll
  • $window changed to $(window)

0

More Related questions