在Jquery中选择$(this)的Direct Child

时间:2010-12-14 20:54:10

标签: jquery

我知道我可以使用$('img',this)来选择$(this)中的所有img元素。

在我目前的情况下,我试图仅操纵$(this)的DIRECT子图像。

是否有选择器?

3 个答案:

答案 0 :(得分:38)

$(this).find('> img')

Read this

答案 1 :(得分:11)

$(this).children('img');

另请参阅:http://api.jquery.com/children/

答案 2 :(得分:4)

$(this).find('> img');

感谢Gabi的回答

编辑:

人们不要向我致敬这是Gabi的回答,直到昨天(https://stackoverflow.com/posts/4444131/revisions

$(this).find('> img', this);

那么,为什么你一直在低估我的答案,而这一直是这样,并回答OP问题?!