[英]Javascript to make div appear after scroll is showing on page load?
我輸入了這段代碼(我從這個答案中提取: 滾動瀏覽頁面的某個點時顯示div),以便在用戶向下滾動頁面時顯示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>
在CSS set display:none
屬性中,不希望在頁面加載時顯示div
相反的效果基本show()和了slideDown(),您可以使用, 淡入()和淡出()或的slideToggle();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.