gpt4 book ai didi

javascript - 返回给定位置的元素(但它不是从该位置开始!)

转载 作者:行者123 更新时间:2023-12-02 20:08:37 24 4
gpt4 key购买 nike

我想返回具有给定左侧位置的元素。

假设我有以下内容:

<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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com