Home >Web Front-end >JS Tutorial >How to implement non-editable jquery input
In jquery, you can use the attr method to add the disabled attribute to the input element to make the input uneditable. The statement is such as "$("#id").attr("disabled","disabled");".
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
Recommended: "jquery video tutorial"
jquery makes input uneditable
In jquery, you can use attr( ) method adds the disabled attribute to the input element to make the input uneditable.
/开启disabled,是input不可以编辑 $("#id").attr("disabled","disabled");
Close method:
//关闭disabled $("#id").removeAttr("disabled");
Writing in js:
//js中是这样写的 document.getElementById("id").disabled = false;
Description:
disabled attribute specifies that the input element should be disabled.
A disabled input element is neither available nor clickable. The disabled attribute can be set until some other condition is met (such as a checkbox being selected, etc.). Then, you need to use JavaScript to remove the disabled value and switch the value of the input element to available.
The above is the detailed content of How to implement non-editable jquery input. For more information, please follow other related articles on the PHP Chinese website!