jQuery 电梯导航
月夕+ 2020-06-21 05:15:46 滚动滚轮时 怎末让导航跟着变不同颜色 划入点击都可以,帮忙看下我是有点懵了,难道思路错了?
$(function() {
var fa = true;
var top = $('.actv').offset().top;
var top1 = $('.con').offset().top;
$('body,html').stop().animate({
scrollTop: 0
})
togg();
function togg() {
if ($(document).scrollTop() >= top1) {
$('.daohangl').slideDown(100);
} else {
$('.daohangl').slideUp(300);
}
if ($(document).scrollTop() >= top) {
$('.dianti').fadeIn(100);
} else {
$('.dianti').fadeOut(300);
}
}
// 滚动 让导航里面每个小板块变不同的颜色
$(window).scroll(function() {
togg();
if (fa) {
$('.eq').each(function(i, e) {
if ($(document).scrollTop() >= $(e).offset().top) {
}
})
}
})
// 点击返回顶部
$('.bctl').on('click', function() {
$('body,html').stop().animate({
scrollTop: 0
});
})
// 点击跳转到不同板块
$('.diant1').on('click', function() {
fa = false;
var index = $(this).index();
var cont = $('.eq').eq(index).offset().top;
$('body,html').stop().animate({
scrollTop: cont + -50,
}, function() {
fa = true;
})
var as = ['#DC143C', '#FF8C00', 'deeppink', 'burlywood', 'goldenrod', '#FF0036']
$('.diant1').eq(index).each(function(i, d) {
i = index;
$(d).css('backgroundColor', as[i])
$(d).siblings().css({
backgroundColor: 'black',
opacity: 0.6
})
})
})
// 划入让每个小板块变不同颜色
$('.diant1').hover(function(){
var index = $(this).index()
var as = ['#DC143C', '#FF8C00', 'deeppink', 'burlywood', 'goldenrod', '#FF0036']
$('.diant1').eq(index).each(function(i, d) {
i = index;
$(d).css('backgroundColor', as[i])
$(d).siblings().css({
backgroundColor: 'black',
opacity: 0.6
})
})
})
})