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

How to eliminate readonly using javascript

青灯夜游
Release: 2021-06-23 16:08:53
Original
5705 people have browsed it

Use JavaScript to eliminate readonly: first use "document.getElementById("id value")" to obtain the element object that needs to be processed; then use the "element object.readOnly=false" statement to remove it.

How to eliminate readonly using javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Use javascript to eliminate readonly

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function makeReadOnly()
  {
  document.getElementById("text1").readOnly=false;
  }
</script>
</head>
<body>

<form>
<input type="text" id="text1" value="Hello World!" readOnly /><br /><br />
<input type="button" onclick="makeReadOnly()" value="去除readOnly" />
</form>

</body>
</html>
Copy after login

Rendering:

How to eliminate readonly using javascript

Description: HTML DOM readOnly attribute

readOnly attribute sets or returns whether the text field is read-only.

Grammar

textObject.readOnly=true|false
Copy after login

[Related recommendations: javascript learning tutorial]

The above is the detailed content of How to eliminate readonly using javascript. 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