Bru*_*uno 6 jquery css-selectors
我确定解决方案很简单,但我无法弄明白:(我需要在一个选择器中组合两个jquery选择器:
$(this) + $('input[type=text]:first')
Run Code Online (Sandbox Code Playgroud)
$(this)是例如div#selected所以结果应该是:
$('div#selected input[type=text]:first').focus();
Run Code Online (Sandbox Code Playgroud)
怎么做?
只需使用.find():
获取当前匹配元素集中每个元素的后代,由选择器过滤.
$(this).find('input[type=text]:first').focus();
Run Code Online (Sandbox Code Playgroud)
或者将上下文设置为this:
$('input[type=text]:first', this).focus();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7499 次 |
| 最近记录: |