开发者

JQuery: accessing LI nodes?

I have the following HTML

<ul id="listing">
<li>...</li>
<开发者_StackOverflow中文版;li>...</li>
<li>...</li>
</ul>

How can I access the 2nd LI inner text?

Can I do

$("#listing li").[1].text()

If not, what is the sytax?


$("#listing li:eq(1)").text();

More about the Index Selector at http://docs.jquery.com/Selectors/eq#index


close

$("#listing li").eq(1).text()

http://docs.jquery.com/Traversing/eq


have a look at the eq selector in jquery

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜