views:

103

answers:

3

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  A: 

This should work:

$(":input:not([readonly='readonly'])")
halfdan
I think just `[readonly]` would work... The existence of the attribute is enough. http://api.jquery.com/has-attribute-selector/
gnarf
A: 

You can use jQuery disabled

$('#target').attr("disabled", true);

so

var testMonkey = $('#element');
if (testMonkey.attr('disabled') == true) {
  //this is NOT read only
} else {
  //this IS read only
}

NOTE: You can also do the same with $('#tbox').removeAttr('readonly');

Neurofluxation
[Read-only is not the same as disabled.](http://www.w3.org/TR/html4/interact/forms.html#h-17.12) The most important difference is that disabled inputs will not be submitted as form data. Also, removing the `readonly` attribute modifies the elements that do have `readonly`; it doesn't exclude elements with that attribute.
BoltClock
`disabled` is slightly different from `readonly`; A `disabled` field does not submit with a form, while a `readonly` does.
Ryan Kinal
Ok my bad. I'll leave this here anyway in case someone else finds it useful.
Neurofluxation
+1  A: 

I suppose you are looking for something like the following:

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

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

elusive