" or ""."/> " or "".">
Home >Web Front-end >HTML Tutorial >How to set read-only in html text box
In HTML, you can achieve read-only function by setting the readonly attribute to the text box element (input or textarea), the syntax is "" or "
The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
In html, there are two types of text box elements:
input
textarea
If you want to make the text box read-only, you only need to set the readonly attribute to the text box element.
The readonly property is a Boolean property.
The readonly attribute specifies that the text area is read-only.
In a read-only text area, the content cannot be modified, but the user can switch to the control through the tab key and select or copy the content.
You can set the readonly attribute to resume the user's use of the text area until certain conditions are met (such as selecting a check box). You can then use JavaScript to remove the value of the readonly attribute to make the text area editable.
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <input type="text" value="测试文本"/><br> <input type="text" value="测试文本" readonly="readonly"/> <hr> <textarea>测试文本</textarea><br> <textarea readonly>测试文本</textarea> </body> </html>##Recommended tutorial: "
html video tutorial》
The above is the detailed content of How to set read-only in html text box. For more information, please follow other related articles on the PHP Chinese website!