如何选择所有的输入和文本区域,除了那些与type=password



到现在为止,我成功地使用了这个选择器:

$('input, textarea')

但问题是这也选择了具有type=password

的输入

我知道我可以这样选择:

$("input[type=text],input:not([type]),textarea")

但是其他类型呢?

我想选择所有没有将type属性设置为password的输入。

我试图使用:not选择器,但无法成功使用。

$("input:not(:password)")

似乎不工作

像这样:

$("input[type!='password'], textarea")

Try

$('input:not([type="password"]), textarea')

jQuery没有:password选择器

相反,您可以使用attributeNotEqual选择器:
$(':input[type!="password"]')

注意这个例子也使用了:input选择器,它选择了所有的输入类型,包括textareaselect元素。

最新更新