开发者

How do you split a JQuery command up

开发者 https://www.devze.com 2023-01-26 21:31 出处:网络
$(\'#something :input\') if I 开发者_如何转开发already have something as an object, ie: var x = document.getElementById(\'something\');
$('#something :input')

if I 开发者_如何转开发already have something as an object, ie:

var x = document.getElementById('something');

How do I do :input on that?

Something like this perhaps?

$(x).(':input')


The equivalent of

$('#something :input')

is

$('#something').find(':input')

Note the space between the two selectors means that :input is a descendant of #something. This means the answer to your problem is

$(x).find(':input')

// Or, using selector context (which is less efficient but less chars)
$(':input', x)

http://api.jquery.com/find/


This should do the trick:

$(':input', x)

It searches for all :inputs that are descendants of x (using x as its context).

0

精彩评论

暂无评论...
验证码 换一张
取 消