Using jquery how do i simply check if it is read only?
this is what i am trying..
$("#item").keydown(function (event) {
//alert(event.keyCode);
if (event.keyCode == 13) {
$("#ok").click();
if ($('#dropLength').prop("disabled") == false) {
$("#dropLength").focus();
return;
}
if ($('#dropUnit').prop("disabled") == false) {
$("#dropUnit").focus();
return;
}
$("#qty").focus();
return ;
}
});
The dropdowns are set to readonly using jquery also:
if ($('#dropLength').find('option').length <= 1) {
$('#dropLength').attr("disabled", "disabled");
}
if ($('#dropUnit').find('option').length <= 1) {
$('#dropUnit').attr("disabled", "disabled");
}
The legacy solution, before 1.6, was to use
.attrand handle the returned value as abool. The main problem is that the returned type of.attrhas changed tostring, and therefore the comparison with== trueis broken (see http://jsfiddle.net/2vene/1/ (and switch the jquery-version)).With 1.6
.propwas introduced, which returns abool.Nevertheless, I suggest to use
.is(), as the returned type is intrinsicallybool, like:Furthermore
.is()is much more natural (in terms of “natural language”) and adds more conditions than a simple attribute-comparison (eg:.is(':last'),.is(':visible'), … please see documentation on selectors).