How can I set the disabled and readonly properties of a <select>
and <input>
element with jQuery? Also can someone please explain the difference. It seems to me that both properties would do the same thing.
Asked
Active
Viewed 91 times
0

Samantha J T Star
- 30,952
- 84
- 245
- 427
-
2http://stackoverflow.com/questions/7730695/whats-the-difference-between-disabled-disabled-and-readonly-readonly-for-te – Tim M. Aug 21 '12 at 04:06
1 Answers
1
$('input,select').attr('disabled','disabled')
$('input').attr('readonly','readonly')
likewise…
$('input,select').removeAttr('disabled')
$('input').removeAttr('readonly')
EDIT: You might want to read about the difference between .prop()
and .attr()
. Although relatively old here's an official documentation covering it.

inhan
- 7,394
- 2
- 24
- 35