如何使用jquery选择第n个孩子的第n个孩子?
问题描述:
我怎么能做这些jQuery中的任何一个?如何使用jquery选择第n个孩子的第n个孩子?
- 第n个孩子的第n个子
- n个子这是图像
编辑的第n个子
var number = (... code ...) ;
.... eq(number)
,所以我不能做这样
什么3210$('li:nth-child(2) li:nth-child(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")
谢谢对不起,我忘了在我的问题中提到,第n个来自一个变量需要另一个做eq()的方式。我修改了我的问题 – byronyasgur
,所以'number'是一个包含子编号的变量?你的问题现在还不清楚。 –
是的......我不明白它怎么不清楚? – byronyasgur