【发布时间】:2015-02-27 13:22:05
【问题描述】:
我输入了这段代码(我从这个答案中提取:Make a div appear when scrolling past a certain point of a page)以在用户向下滚动页面时显示一个 div。
问题是:页面一加载,div就出现,当用户滚动时消失,当滚动> 700时又重新出现。
如何让 div 在页面加载开始时不显示?
谢谢!
<script>
// Get the headers position from the top of the page, plus its own height
var startY = 700;
$(window).scroll(function(){
checkY();
});
function checkY(){
if( $(window).scrollTop() > startY ){
$('.scroll-up').slideDown();
}else{
$('.scroll-up').slideUp();
}
}
// Do this on load just in case the user starts half way down the page
checkY();
</script>
【问题讨论】:
标签: javascript jquery