admin管理员组文章数量:1388039
Is there a selector available in jQuery to select elements which have a specific position of the page, for example all elements that have an offsetTop bigger than, say, 100px?
I tried:
$('span[offsetTop>100]')
because just as we can check if an attribute equals to some value, I thought it might be possible to check if an attribute is larger than some value. This, however, does not work. Is this possible at all?
Is there a selector available in jQuery to select elements which have a specific position of the page, for example all elements that have an offsetTop bigger than, say, 100px?
I tried:
$('span[offsetTop>100]')
because just as we can check if an attribute equals to some value, I thought it might be possible to check if an attribute is larger than some value. This, however, does not work. Is this possible at all?
Share Improve this question edited Feb 27, 2012 at 13:14 pimvdb asked Feb 8, 2011 at 18:22 pimvdbpimvdb 155k80 gold badges311 silver badges356 bronze badges1 Answer
Reset to default 9You'd need to use the filter()
(docs) method to filter <span>
elements by their offset:
$('span').filter(function() {
return $(this).offset().top > 100;
});
本文标签: javascriptjQuery selector by position on page availableStack Overflow
版权声明:本文标题:javascript - jQuery selector by position on page available? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744521412a2610475.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论