With the release of jQuery 1.6, the recommendation on SO has been to generally start using prop() where you used to use attr().
What happens when I want make an element readonly?
$('.control').prop('readonly', 'readonly');
$('.control').prop('readonly', true);
Neither of these seem to make the control readonly. Is making an element readonly the exception to the rule?
Try this:
I think of it like this: .attr() gets the default value in the html markup while .prop() gets/sets the value dynamically. Look at the following:
The api documentation says this:
The problem is that the property name is case-sensitive. Try:
Though really I don't know why this requires jQuery. This works just as well: