JQuery: find children from an existing selector

I'm sure the solution is simple, but I can't figure it out :( I need to combine two jquery selectors into one selector:

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

$ (this) is, for example, div #, so the result should be:

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

How to make?

+6
jquery css-selectors
source share
4 answers

Just use .find() :

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

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

or set the context to this :

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

You can use several comma-separated selectors:

http://api.jquery.com/multiple-selector/

+3
source share

I think you are looking for:

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

It will focus the input field in the context of the div#selected

+1
source share
 $(this).children('#inpouter[type=test]:first').focus(); 

Gotta do the trick ...

0
source share

All Articles