0
我試圖設置CSS屬性只爲顯示的元素!=無找到.filter()後的第n個孩子
使用.filter()
$("#container > li").filter(':not(:hidden)').first().css("margin-right", "0");
後,這個工程的第一個孩子但我想還爲第n個孩子(3N + 1),因爲它也算隱藏要素時計算第n個孩子
$("#container > li:nth-child(3n+1)").filter(':not(:hidden)').css("margin-right","0");
我也試過
0這是不行的$("#container > li").filter(':not(:hidden)').find(':nth-child(3n+1)').css("margin-right", "0");
任何想法如何爲每4個孩子設置css後過濾那些未隱藏的?
是否有類似.first()的nth-child()選擇器?
爲什麼''===明確有必要嗎? '(i + 1)%4'將始終返回一個整數。 –
工作非常感謝@ raina77ow – baaroz
@ItayGrudev一個字 - [linter](http://www.jshint.com/)。我們的風格指南可以防止任何'=='的使用 - 我們絕對不是一個人。 )當然,如果_really_必要,可以用註釋覆蓋它,但這不是那種情況。 – raina77ow