鼠标的滚轮事件

实现“鼠标滚动时,动态改变相应的样式或者效果”

代码如下:

$(window).scroll(function() {
            var scrolls = $(this).scrollTop();
            $(".context_block").each(function(){ //类名为“context_block”的块级元素
                var height = $(this).height();
                if($(this).position().top + height-60> scrolls){
                    var _index = $(".context_block").index($(this));
                    $(".menu  a").parent().siblings().contents("a").removeClass("hover_mobileLink");    
                    $($(".menu  a")[_index]).addClass("hover_mobileLink");//动态改变class为“menu” 的块级元素下的a标签的样式(添加或者删除某个类)
                    return false;
                }
            });
        });

posted @ 2013-02-27 16:11  Nancy_0324  阅读(156)  评论(0编辑  收藏  举报