2011-08-01 30 views

回答

4
$('#select_id:nth-child(4n)') 

Here is a demo

+0

它不會只選擇4格嗎?我想元素%4 == 0? – eugeneK

+0

@eugeneK:你看過演示了嗎?不,它不會選擇只有第四個div,而是所有的模數將等於0的DIV。 – Shef

+0

對不起,錯過了4n,以爲你喜歡其他人只發布4 ...謝謝 – eugeneK

0

這樣:

var div = $("div:eq(3)"); 
+0

它不會只選擇4格嗎?我想元素%4 == 0 – eugeneK

+0

對不起。你是對的。 – user278064

0

你可以使用過濾器 -

$('div').filter(function(index) { 
    return (index + 1) % 4 === 0; 
}) 
相關問題