首页 > 其他分享 >jquery品优购电梯导航修复小bug并加上类名-73

jquery品优购电梯导航修复小bug并加上类名-73

时间:2023-02-10 10:03:30浏览次数:44  
标签:jquery function fixedtool color height current 73 background bug


<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./js/jquery.min.js"></script>
<style>
.recommend {
height: 1000px;
background-color: red;
}

.fixedtool {
width: 100px;
height: 101px;
background-color: pink;
}

.jiadian {
width: 300px;
height: 200px;
background-color: salmon;
}

.shouji {
width: 300px;
height: 200px;
background-color: salmon;
}

.current {
background-color: black;
}
</style>
</head>

<body>
<div class="recommend">1</div>
<div class="fixedtool">
<ul>
<li class="current">家电</li>
<li>手机</li>
</ul>
</div>
<div class="floor ">
<div class="jiadian w">家电</div>
<div class="shouji w">手机</div>
</div>
<div class="jiadian">

</div>
<script>
$(function() {
function toggleTool() {
if ($(document).scrollTop() >= toolTop) {
$(".fixedtool").fadeIn();
} else {
$(".fixedtool").fadeOut();
};
}
var toolTop = $(".recommend").offset().top;
toggleTool();
$(window).scroll(function() {
toggleTool();
});
//点击导航栏得到相应内容
$(".fixedtool li").click(function() {
//每次点击li去往页面要去的位置
//选出索引号的值去除他的位置
console.log($(this).index());
var current = $(".floor .w").eq($(this).index()).offset().top;
//页面滚动效果
$("body,html").stop().animate({
scrollTop: current
});
//点击之后添加current
$(this).addClass("current").siblings().removeClass();
})
})
</script>
</body>

</html>

jquery品优购电梯导航修复小bug并加上类名-73_滚动效果

 

标签:jquery,function,fixedtool,color,height,current,73,background,bug
From: https://blog.51cto.com/u_15460007/6048618

相关文章

  • jquery-品优购电梯导航-71
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Document</t......
  • jquery品优购电梯导航2-72
     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Document<......
  • jquery-todolist删除数据1-66
     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>todoList......
  • jquery-本地存储实现数据录入
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>todoList待......
  • jquery-todolist本地存储加载到页面
     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>todoList......
  • jquery-回车把数据存储到本地存储里面-63
     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>todoList......
  • jquery位置3-60
     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Document<......
  • jquery位置2-59
     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Document<......
  • jquery位置1
      <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Documen......
  • jquery-全选按钮下-30
     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>Document<......