html
<style>
.nav1.on, .nav1:hover {
background-color: #ea5c31;
}
</style>
<div class="nav" style="display: block;">
<p><a href="javascript:scrollTo(1000);" onclick="PTTSendClick('btn','ts','点击探索');" class="btn_ts"></a></p>
<a href="javascript:scrollTo(1000);" onclick="PTTSendClick('btn','nav1','导航1');" class="nav1 nav2 on"></a>
<a href="javascript:scrollTo(2070);" onclick="PTTSendClick('btn','nav2','导航2');" class="nav1"></a>
<a href="javascript:scrollTo(2650);" onclick="PTTSendClick('btn','nav3','导航3');" class="nav1 nav2"></a>
<a href="javascript:scrollTo(3500);" onclick="PTTSendClick('btn','nav4','导航4');" class="nav1">1</em></a>
<a href="javascript:scrollTo(4300);" onclick="PTTSendClick('btn','nav5','导航5');" class="nav1"></a>
<a href="javascript:scrollTo(5300);" onclick="PTTSendClick('btn','nav6','导航6');" class="nav1 nav2"></a>
</div>
<script>
//导航
$(".nav a").click(function(){
$(this).addClass("on").siblings().removeClass("on")
})
$(window).scroll(function(){
//查看高度
console.log($(document).scrollTop())
if($(document).scrollTop()<700){
$('.nav').css('display','none')
}else{
$('.nav').css('display','block')
}
})
function cc(nums,last){
$(".nav").find('a:eq('+nums+')').addClass('on').siblings().removeClass('on');
if(last-nums==1){
$(".nav").find('a:eq('+last+')').addClass('on')
}
//a是需要变得元素
}
window.scrollTo = (function() {
var targets = jQuery(document.documentElement).add(document.body);
return function(n) {targets.stop().animate({scrollTop: n});
}
})();
//点击跳转到指定高度
var btntab1=document.querySelector(".btntab1")
var cont=document.querySelector(".img2nbox").offsetTop
btntab1.onclick=function(){
document.documentElement.scrollTop = cont;
}
</script>
摘自:https://nz.qq.com/cp/a20210113janat/index.html