What is the html read-only attribute?

藏色散人
Release: 2021-05-19 16:20:17
Original
4789 people have browsed it

htmlThe read-only attribute refers to the readonly attribute, which stipulates that the input field is read-only; the readonly attribute prevents users from modifying the value until certain conditions are met; the setting syntax for this attribute is "".

What is the html read-only attribute?

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, DELL G3 computer

The readonly attribute specifies that the input field is read-only.

Read-only fields cannot be modified. However, users can still tab to the field and select or copy its text.

The readonly attribute prevents users from modifying the value until certain conditions are met (such as a checkbox being selected). Then, you need to use JavaScript to eliminate the readonly value and switch the input field to an editable state.

The readonly attribute can be used with or .

Syntax

<input readonly="value">
Copy after login

Attribute value, readonly sets the input field to read-only.

Example:

HTML form with two text fields and a submit button:

Code

<html>
<body>

<form action="/example/html/form_action.asp" method="get">
  
  <p>Name:<input type="text" name="email" /></p>

  <p>Country:<input type="text" name="country" 
  value="China" readonly="readonly" /></p>
  
  <input type="submit" value="Submit" />
</form>

<p>请在提交按钮上单击,输入会发送到服务器上名为 "form_action.asp" 的页面。</p>

</body>
</html>
Copy after login

Running effect :

What is the html read-only attribute?

Recommended learning: "HTML video tutorial" "css video tutorial"

The above is the detailed content of What is the html read-only attribute?. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!