Make else in jquery to control scrolltop

0

I have a% div of%, that when it hits 31px it stays with .menuFixo , otherwise, top: 0 , did with Jquery, but did not work. >

$(window).scroll(function () {
    if ($(window).scrollTop() > 31) {
        $(".menuFixo").css("top", "0");
    };
    else if ($(window).scrollTop() < 31) {
        $(".menuFixo").css("top", "31px");
    };

});
    
asked by anonymous 19.01.2015 / 17:09

1 answer

1

Look if it can help you.

        $(document).ready(function () {
          $(window).scroll(function () {
            if ($(this).scrollTop() > 31) {
                $(".menuFixo").css("top", "0");
          }else {
                $(".menuFixo").css("top", "31px");
          }
                });
        });
    
20.01.2015 / 15:27