jQuery “not readonly” selector

2019-01-17 18:51发布

I'm looking for something along the lines of...

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

but struggling to find the syntax.

Any pointers? thanks

5条回答
放我归山
2楼-- · 2019-01-17 19:21

I recently did something similar like this:

$('#element').find(':input').not(':input[readonly]');
查看更多
做自己的国王
3楼-- · 2019-01-17 19:32

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

$(this).context.readOnly == false / true
查看更多
家丑人穷心不美
4楼-- · 2019-01-17 19:41

This should work:

$(":input:not([readonly])")
查看更多
手持菜刀,她持情操
5楼-- · 2019-01-17 19:44

I suppose you are looking for something like the following:

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

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

查看更多
对你真心纯属浪费
6楼-- · 2019-01-17 19:46
$('input:not([readonly])')

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

查看更多
登录 后发表回答