我想从以下输入字段中删除readonly属性:
<input id="cno" name="cno" type="number" class="form-control" readonly />
<button type="button" id="no-edit" class="btn btn-warning">Edit</button>
我尝试使用jQuery(1.11)删除按钮上的属性。
$("#no-edit").click(function() {
$("#cno").removeProp('readonly');
});
我也尝试过使用:
$("#no-edit").click(function() {
$("#cno").removeAttr('readonly');
});
请帮忙!我不明白为什么会失败。
答案 0 :(得分:2)
答案 1 :(得分:1)
将它包装在document.ready上为我工作。
$(document).ready(function () {
$("#no-edit").click(function() {
$("#cno").removeAttr('readonly');
});
})