nth-child(2)什么意思???http://docs.jquery.com/Selectors/nthChild#index
Selectors/nthChild
From jQuery JavaScript Library
Jump to: navigation, search« Back to Selectors
[edit]
:nth-child(index/even/odd/equation) * Overview
* ExamplesMatches all elements that are the nth-child of their parent or that are the parent's even or odd children.
While :eq(index) matches only a single element, this matches more than one: One for each parent with index. Multiple for each parent with even, odd, or equation. The specified index is one-indexed, in contrast to :eq() which starts at zero. * Demo
* View SourceFinds the second li in each matched ul and notes it.$("ul li:nth-child(2)").append("<span> - 2nd!</span>");
Selectors/nthChild
From jQuery JavaScript Library
Jump to: navigation, search« Back to Selectors
[edit]
:nth-child(index/even/odd/equation) * Overview
* ExamplesMatches all elements that are the nth-child of their parent or that are the parent's even or odd children.
While :eq(index) matches only a single element, this matches more than one: One for each parent with index. Multiple for each parent with even, odd, or equation. The specified index is one-indexed, in contrast to :eq() which starts at zero. * Demo
* View SourceFinds the second li in each matched ul and notes it.$("ul li:nth-child(2)").append("<span> - 2nd!</span>");
:nth-child(even|odd) 返回偶数(Even) 或奇数(Odd) 子元素. 如:li:nth-child(even) 返回所有作为子元素的li项的偶数元素.
:nth-child(Xn+Y) 返回Xn+Y计算结果的第n个子元素.如果Y为0,则被忽略. 如:li:nth-child(3n) 返回所有作为子元素的li项的每第3n个元素
<li>John</li>
<li>Karl</li>
<li>Brandon</li>
</ul>
<ul>
<li>Glen</li>
<li>Tane</li>
<li>Ralph</li>
</ul>$("ul li:nth-child(2)")结果:
<li>Karl</li>, <li>Tane</li>