鼠标滚轮距离顶部大于一定的距离变换导航条样式,以及点击导航按钮到达对应的一屏

/**
* Created by Administrator on 2018/5/11.
*/
$(function(){

function whell() {

if ($(window).scrollTop() > 90)
{
$("nav.navbar").addClass("nav2");
}
else
{
$("nav.navbar").removeClass("nav2");
}

}
whell();
$(window).scroll(function(){

whell();

});

var index;
$("ul.nav a").click(function() {
index = $(this).parent().index();
$(this).addClass("red").parents().siblings().find("a").removeClass("red");
$("html,body").animate({scrollTop: $('.all>div').eq(index).offset().top}, 300);
whell();
})

});
posted @ 2018-05-14 09:11  yaomengli  阅读(348)  评论(0编辑  收藏  举报