Readonly property not working
"readonly" property not working. Please check my code below http://jsfiddle.net/KZArL/
Even after setting readonly still i can change value...I am using the below code
$('select').prop('readonly','readonly');
If i disab开发者_如何学JAVAle post won't carry disabled value...
AFAIK, you cannot make a select read only, what you need to do is disable it:
$('select').prop('disabled', true);
Bare in mind that disabled form fields are not submitted with the form.
<select>
doesn't have a readonly attribute, which is probably the issue you're seeing.
See the MDN on <select>
for more details.
On another question though, I just made a very simple selection change prevention plugin for jQuery if you're interested.
You should use disabled:
$('select').prop('disabled', true);
try this:
$('select').attr('readonly', true);
精彩评论