开发者

Jquery, Selector syntaxt help, get all text fileds

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 th开发者_如何转开发at 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.

var context = $('#container');
$('textarea, :text', context);

is equivalent to using .find()

$('#container').find('textarea, :text');

filter filters the current selected elements, it does not search its descendants. So your second expression would return the element selected by $('#container') if it is a textarea or some text input field.

To make use of native functions in recent browsers you should use input[type="text"] instead of jQuery's :text.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜