JQuery:从现有的选择器中查找子元素 [英] JQuery: find child elements from an existing selector

查看:229
本文介绍了JQuery:从现有的选择器中查找子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定解决方案很简单,但我不能弄清楚:(
我需要在一个选择器中组合两个jquery选择器:

Im sure the solution is simple but I cant figure it out :( I need to combine two jquery selectors in one selector:

$(this) + $('input[type=text]:first')

$(this)是eg,所以结果应该是:

$(this) is e.g div#selected so the result should be:

$('div#selected input[type=text]:first').focus();


推荐答案

只需使用 .find()


Get the descendants of each element in the current set of matched elements, filtered by a selector.



$(this).find('input[type=text]:first').focus();

或将 上下文 设置为 this

$('input[type=text]:first', this).focus();

这篇关于JQuery:从现有的选择器中查找子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆