// 锚点自动选择
function checkscroll() {
if ($('#p1').length <= 0) { return; }
// 为页面添加页面滚动监听事件
var wst = $(window).scrollTop() + 200 // 滚动条距离顶端值
for (i = 1; i < 6; i++) { // 加循环
if ($("#p" + i).offset().top <= wst) { // 判断滚动条位置
$('#nav li').removeClass("current"); // 清除c类
$('#nav li:nth-child(' + (i) + ')').addClass("current"); // 给当前导航加c类
}
}
}
html 锚点追踪
最新推荐文章于 2024-04-11 08:09:38 发布