How do you split a JQuery command up
$('#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 :input
s that are descendants of x
(using x
as its context).
精彩评论