2010-02-07 52 views
0
$('.mydiv ul li:nth-child(4)').addClass("nth"); 

至少有8個li在那裏,但它只選擇第4但不是第8?jQuery:nth-​​child只選擇一個?

+0

它爲什麼會選擇8,當你有4個存在? – 2010-02-07 16:50:58

+0

是不是表示選擇EVERY 4th? – 3zzy 2010-02-07 16:51:52

+0

編號:http://api.jquery.com/nth-child-selector/ – womp 2010-02-07 16:53:24

回答

5
$('.mydiv ul li:nth-child(4n)').addClass("nth"); 

講究4n

+0

AAAH!謝謝 :) – 3zzy 2010-02-07 16:58:26