Home > Web Front-end > JS Tutorial > body text

How to implement non-editable jquery input

藏色散人
Release: 2023-01-04 09:36:39
Original
4310 people have browsed it

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");
Copy after login

Close method:

//关闭disabled
 
$("#id").removeAttr("disabled");
Copy after login

Writing in js:

//js中是这样写的
document.getElementById("id").disabled = false;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template