2010-05-28 53 views

回答

1

为了展示它是如何工作与变量n:

$('.mydiv:eq('+n+') img') 

您使用+运营商在JavaScript中Concat的。

2

就快:

// Select all img elements in the 1st .mydiv: 
$('.mydiv:eq(0) img') 

// Select all img elements in the 3rd .mydiv: 
$('.mydiv:eq(2) img') 

:eq()更多的例子在http://api.jquery.com/eq-selector


要使用一个变量中:eq,请执行下列操作

// Select all img elements in the `n`th .mydiv: 
$('.mydiv:eq('+n+') img') 
+0

谢谢安迪!我会如何在'eq()'变量中创建这个数字? – Mohammad 2010-05-28 11:07:04

1
$("div.myclass:eq(n) img")