I have a selector that works like this:
$('#container textarea, #container :text');
However this does not work.
$('#container').filter('textarea, :text');
Though, I have read that the filter command is the same as:
var context = $('#container');
$('textarea, :text', context);
Which does work
How can i get the the selector to work in the second expression?
Wherever you read this, it is wrong.
is equivalent to using
.find()filterfilters the current selected elements, it does not search its descendants. So your second expression would return the element selected by$('#container')if it is atextareaor some text input field.To make use of native functions in recent browsers you should use
input[type="text"]instead of jQuery’s:text.