jQuery查找并列出特定DIV内UL中的所有LI元素 [英] jQuery Find and List all LI elements within a UL within a specific DIV
问题描述
我有3个UL列,每个动态UL容器可以有0-9个LI容器(最终更多)的任何地方。我所有的LI元素都有一个属性rel,我试图最终找到该属性,并将其用于该父DIV中所有LI元素上的其他元素。我最终希望找到更多基于每个,但不是最不rel ..任何想法我可以实现与jQuery?示例:
< ul id =column1>
< li rel =1>信息< / li>
< li rel =2>资讯< / li>
< li rel =3>资讯< / li>
< / ul>
< ul id =column2>
< li rel =4>信息< / li>
< li rel =5>信息< / li>
< li rel =6>资讯< / li>
< / ul>
< ul id =column3>
< li rel =7>信息< / li>
< li rel =8>信息< / li>
< li rel =9>信息< / li>
< / ul>
这些元素也都是可排序的。所以,当我得到他们的名单,我想也保持他们从每一列的顶部到底部的顺序。
我已经尝试过find(),父母()和类似的,也许我正在接近错误。但它仍然值得一提的帮助提出一个想法
你在想这样的事情吗? b
$ b $ $ $ $ $ $ $ $'$'$'$' rel'); //这是你的rel值
});
I have 3 Columns of ULs each a Dynamic UL container that can have anywhere from 0-9 LI containers (eventually more). All my LI elements have an attribute "rel" which I am trying to ultimately find that attribute and use it for something else on all LI elements within that parent DIV. I do eventually want to find more based on each but for not the very least the rel.. Any Ideas how I can achieve that with jQuery? Example:
<ul id="column1">
<li rel="1">Info</li>
<li rel="2">Info</li>
<li rel="3">Info</li>
</ul>
<ul id="column2">
<li rel="4">Info</li>
<li rel="5">Info</li>
<li rel="6">Info</li>
</ul>
<ul id="column3">
<li rel="7">Info</li>
<li rel="8">Info</li>
<li rel="9">Info</li>
</ul>
these elements are all sortable as well. So when I get a list of them I want to also keep them in the order they were found from top to bottom of each column.
I have tried find(), parent(), and similar, maybe I am approaching it wrong. But its still worth mentioning to help come up with an idea
Are you thinking about something like this?
$('ul li').each(function(i)
{
$(this).attr('rel'); // This is your rel value
});
这篇关于jQuery查找并列出特定DIV内UL中的所有LI元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!