在页面滚动并处于某个位置时执行某些操作 [英] Do something when page is scrolling and have some position
本文介绍了在页面滚动并处于某个位置时执行某些操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在页面滚动方面有点问题... 当我向下滚动页面时,如果窗口距顶部位置有100px,我想更改一些CSS ... 这是我的代码.很多帮助.
i have a little problem with page scrolling... I wanna to change some css when i'm scrolling page down and if window have 100px from top position... This is my code. Much thx for help.
$(document).ready(function(){
$(window).scroll(function(){
if ($(window).scroll(100)){
$('.ufo').css('right','800px');
}
});
});
推荐答案
尝试一下:
$(document).ready(function(){
$(window).scroll(function(){
if ($(window).scrollTop() > 100){
$('.ufo').css('right','800px');
}
});
});
这篇关于在页面滚动并处于某个位置时执行某些操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文