How can I remove the readonly
attribute when the Edit
button is clicked? My codes is working if clicked but after one second the input form is back to readyonly
.
<input class="form-control" name="fullname" value="<php echo $fullname; ?>" readonly/>
<button class="btn btn-primary" id="btnEdit" > edit </button>
<script>
$(document).ready(function(){
$('#btnEdit').click(function(){
$("input[name='fullname']").attr("readonly", false);
});
});
</script>
You should use jQuery removeAttr
$(document).ready(function(){
$('#btnEdit').click(function(){
$("input[name='fullname']").removeAttr( "readonly" );
});
});
try this you have to use removeAttr reference link
<script>
$(document).ready(function()
{
$('#btnEdit').click(function()
{
$("input[name='fullname']").removeAttr("readonly");
});
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.