A really simple question I'm sure but...
一个很简单的问题,但是…
I have an unordered list, in which some amount of the list items have been slid up. I want to extract information from spans within the visible list items only, using an $.each loop.
我有一个无序列表,其中一些列表项已经滑了上来。我想只使用$,从可见列表项中提取信息。每一个循环。
I want to write something along these lines to access this information but I don't know what the right parameter is:
我想沿着这些线写一些东西来获取这些信息,但是我不知道正确的参数是什么:
$("li.class").each(function(){
if ("li.class" *isn't hidden*) {
// get information from span
}
})
The best I can come up with is adding a class each time a list item is slid up and then removing that class when it slides back down, which I guess would be fine, but I'm suspecting jQuery already has something in place.
我所能想到的最好的方法是每次拖拽一个列表项时都添加一个类,然后在返回时删除这个类,我想这是可以的,但是我怀疑jQuery已经有了一些东西。
Thanks!
谢谢!
2 个解决方案
#1
1
Something like this:
是这样的:
$(function() {
$('li.class:visible').each(function() {
});
});
#2
2
You can use the :visible
pseudo selector:
您可以使用:可见伪选择器:
$("li.class:visible").each(function() {
// get information from span, like ...
$("span", this).text();
})
#1
1
Something like this:
是这样的:
$(function() {
$('li.class:visible').each(function() {
});
});
#2
2
You can use the :visible
pseudo selector:
您可以使用:可见伪选择器:
$("li.class:visible").each(function() {
// get information from span, like ...
$("span", this).text();
})