JQuery“ not readonly”选择器

我在找一些类似..。

$(':input:not(readonly)') // all inputs which are not readonly

但是很难找到语法。

有什么建议吗? 谢谢

53424 次浏览

This should work:

$(":input:not([readonly])")

I suppose you are looking for something like the following:

$('input:not([readonly="readonly"])')

Have a look at jQuery's various attribute-selectors.

$('input:not([readonly])')

would cover readonly, readonly="true" and readonly="readonly"

I recently did something similar like this:

$('#element').find(':input').not(':input[readonly]');

I would like to add another answer that works for me, using context https://api.jquery.com/context/

$(this).context.readOnly == false / true