Reputation: 399
I'm having trouble with my jQuery syntax. Could someone show me how to iterate through all controls on a form that have the readonly attribute, remove the readonly attribute, and make then disabled instead? Thank you.
Upvotes: 1
Views: 4616
Reputation: 5491
$('#your_form_id [readonly]').removeAttr("readonly").prop("disabled",true);
Upvotes: 0
Reputation: 4464
$("#formID").each('input[readonly="readonly"]', function () {
$(this).removeAttr("readonly");
$(this).attr("disabled", true);
});
Not sure if you are doing this on page load, or on a link/button click, but this is a start.
Upvotes: 1
Reputation: 92983
$('input[readonly="readonly"]').removeAttr("readonly").prop("disabled",true);
Upvotes: 3