Home >Web Front-end >JS Tutorial >How to implement non-editable jquery input

How to implement non-editable jquery input

藏色散人
藏色散人Original
2020-12-09 09:11:344347browse

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");".

How to implement non-editable jquery input

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn