我想返回具有给定左侧位置的元素。
假设我有以下内容:
<ul class="first" style="width:840px;left:-60px;"></ul>
<ul class="first" style="width:840px;left:0px;"></ul>
<ul class="first" style="width:840px;left:780px;"></ul>
我想返回left: 240px;
后面的UL
var left = $('ul').filter(function() {
return $(this).position().left == 240;
});
console.log(left);
我尝试了上述方法,但没有返回任何结果!
最佳答案
var behindsUL = $('.capture .captureButtons ul').filter(function() {
var left = $(this).position().left;
return left >= 240 AND left <= 280;
});
console.log(behindsUL);
如果存在诸如“&&”之类的 XML 语法冲突,您将不会走得太远...您应该找到解决方案
关于javascript - 返回给定位置的元素(但它不是从该位置开始!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7188675/