滚动停止后淡入菜单

时间:2013-10-24 20:11:25

标签: javascript jquery html

当停止滚动时,如何使菜单淡入!当你向后滚动到顶部或将鼠标悬停在它上面时它会消失。

$(function() {
$(window).scroll(function(){
    var scrollTop = $(window).scrollTop();
    if(scrollTop != 0)
        $('#nav').stop().animate({'opacity':'0.2'},400);
    else   
        $('#nav').stop().animate({'opacity':'1'},400);
});

$('#nav').hover(
    function (e) {
        var scrollTop = $(window).scrollTop();
        if(scrollTop != 0){
            $('#nav').stop().animate({'opacity':'1'},400);
        }
    },
    function (e) {
        var scrollTop = $(window).scrollTop();
        if(scrollTop != 0){
            $('#nav').stop().animate({'opacity':'0.2'},400);
        }
    }
);
});

0 个答案:

没有答案