开发者

JQuery: accessing LI nodes?

开发者 https://www.devze.com 2022-12-13 22:41 出处:网络
I have the following HTML <ul id=\"listing\"> <li>...</li> <开发者_StackOverflow中文版;li>...</li>

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

精彩评论

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