scroll 滚动到指定位置触发事件 and 点击一按钮/链接让页面定位在指定的位置

scroll 滚动到指定位置触发事件:
$(function(){
$(window).scroll(function() {
var s =$(window).scrollTop();
if (s>=782) {//782是导航条离页面顶部的距离(px)
$('.nav').addClass('fixednav');
}
else{
$('.nav').removeClass('fixednav');
}
});
});
.fixednav{
position:fixed;
top:0px;
left:0px;
100%;
z-index:100000;
_position:absolute;
_top:expression(eval(document.documentElement.scrollTop));
}

点击一按钮/链接让页面定位在指定的位置:
<div class="nav">
<a href="#aaa">导航1</a>
<a href="#bbb">导航2</a>
<a href="#ccc">导航3</a>
<a href="#ddd">导航4</a>
</div>


通过锚点实现
<a name="aaa" id="aaa"></a>
<a name="bbb" id="bbb"></a>
<a name="ccc" id="ccc"></a>
<a name="ddd" id="ddd"></a>

鼠标滚动到底部事件:
$(window).scroll(function() {
if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
$(".foot").css('opacity','1');
} else {
$(".foot").css('opacity','.3');
}
});
 
 
 
原文地址:https://www.cnblogs.com/mo-cha/p/6023313.html