I have the following input:
How c
simply add the following attribute
// for disabled i.e. cannot highlight value or change
disabled="disabled"
// for readonly i.e. can highlight value but not change
readonly="readonly"
jQuery to make the change to the element (substitute disabled
for readonly
in the following for setting readonly
attribute).
$('#fieldName').attr("disabled","disabled")
or
$('#fieldName').attr("disabled", true)
NOTE: As of jQuery 1.6, it is recommended to use .prop() instead of .attr(). The above code will work exactly the same except substitute .attr()
for .prop()
.