jqueryでこれらのいずれかを行うにはどうすればよいですか?
- n番目の子のn番目の子
- n 番目の子の最初の子
- 画像である n 番目の子の子孫 (子または孫)
編集:変数を使用して、このように「子」にアクセスしています
var number = ( ... code ...) ;
.... eq(number)
だから私は次のようなことはできません
$('li:nth-child(2) li:nth-child(2)')
2つを組み合わせる?
//1
$(":nth-child(2) :nth-child(3)")
//2
$(":nth-child(2) :first-child")
//3
$(":nth-child(2) img")
CSS スタイルシートの場合と同じ方法で行います。
var number = 2;
//1
$(":nth-child(" + number + ") :nth-child(" + number + ")")
//2
$(":nth-child(" + number + ") :first-child")
//3
$(":nth-child(" + number + ") img")