低于防止DIV我有一个HTML一样,像这样:从去折叠
<div id="window">
<p>Random length of text</p>
<p>Random length of text</p>
<p>Random length of text</p>
<div id="comment"> input ...</div>
</div>
文本是随机的。我想要做的是,如果id =“comment”从页面上滚动下来,例如下面的折叠,那么我想添加一个“fixed”类,这样我就可以确保id =“comment始终可见该页面。
我想这样的事情,但它是不工作...想法?
$('#comment').offset().top
$('window').scrollTop()
Thaks
像每一个jQuery的API文档页面http ://api.jquery.com/animate/只有在您向下滚动到它们后才会加载用户评论。也许你可以在那里找到如何检查这个! – Simon 2011-01-10 07:37:18
他们还会进行轮询检查滚动状态:http://bytes.com/topic/javascript/answers/150705-window-scroll-detection – Simon 2011-01-10 07:45:19