Reputation: 720
I have multiple input text boxs all are by default read-only.
I want to Remove readonly attribute for all the input element within my form instead of particular element, i dont have any idea that with the jQuery how i can select all input and remove the readonly attributes if are added.
Html :
<input type="text" name="fistname" readonly="true">
<input type="text" name="lastname" readonly="true">
<input type="text" name="emailaddres" readonly="true">
<input type="text" name="password" readonly="true">
<input type="button" name="edit" id="edit">
Jquery :
$(document).ready(function(e){
$(document).on("click","#edit",function(e){
// What should i do here..?
});
});
Upvotes: 0
Views: 8371
Reputation:
$('#edit').click(function (){
$('input[type=text]').removeAttr('readonly');
});
Upvotes: 0
Reputation: 20740
Use removeAttr()
method like following.
$(document).on("click","#edit",function(e){
$('input[type=text]').removeAttr('readonly');
//$(':input').removeAttr('readonly'); //if want to select all types of form controls
});
Upvotes: 0
Reputation: 2677
$('input.canEdit').attr('readonly', false);
and add a class to all input elements you wants to allow user available to edit;
Upvotes: 0
Reputation: 133403
You should use prop()
to set the properties
$(':input').prop('readonly', false)
OR, Use removeAttr()
method
$(':input').removeAttr('readonly')
References
Upvotes: 7