私は次のコードを利用しています:
.c-1:first-child, .c-2:first-child, .c-1:nth-child(4n+1) { margin-left: 0; }
これはうまく機能していますが、IE8 などの nth-child をサポートしていないブラウザーではこれを模倣する必要があります。
クラスを追加するためにこの jQuery コードを試しましたが、何も起こりません。このコードは正しいですか?
// Support nth child in IE8
$('.c-1:first-child').addClass('remove');
$('.c-2:first-child').addClass('remove');
$('.c-1:nth-child(4n+1)').addClass('remove');