jQuery实现鼠标滚轮动态改变样式或效果_jquery

WBOY
Release: 2016-05-16 16:22:05
Original
1271 people have browsed it

代码如下:

复制代码代码如下:

$(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;
}
});
});

核心代码很简单,实现的效果却非常不错,这里推荐给小伙伴们。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!