Possible reasons why the input type="reset" tag in HTML is invalid (does not work).

Possible reasons why the input type="reset" tag in HTML is invalid (does not work).
When using the <html:reset> tag, sometimes we will find that the reset button is invalid and clicking the button does not clear the input box.

Here’s why:

The w3c website has this description (http://www.w3school.com.cn/htmldom/dom_obj_reset.asp)
"For each occurrence of the <input type="reset"> tag in an HTML form, a Reset object is created. When the reset button is clicked, the values ​​of all input elements in the containing form are reset to their default values. The default values ​​are specified by the HTML value attribute or the JavaScript defaultValue attribute."

This means that if the value attribute of this textarea is set, the reset button will restore the textarea to the value of this value attribute instead of being empty.

The conclusion is as follows:

Reset does not clear the value of the input box, but restores the value of the input box to the value specified by the value attribute.
This becomes clear after looking at the following example. Save the following HTML code as a .html file, open it with a browser, modify the content of the input box, and click the reset button to see the effect.

<form>
<input type="textarea" value="defaultValue"/>
<input type="reset" />
</form>

However, on the query result page, we sometimes hope that the value attribute has a value (the input condition of the last query), so we cannot use the reset tag to implement the clearing function, note that it is clearing.

The simulation method is as follows: use the button tag instead of the reset tag, and use js to set the value of the textarea to empty.

<<:  Summary of several submission methods of HTML forms

>>:  Example of implementing a seamless infinite loop of background using CSS animation

Recommend

Understand the initial use of redux in react in one article

Redux is a data state management plug-in. When us...

Docker generates images through containers and submits DockerCommit in detail

Table of contents After creating a container loca...

Detailed explanation of Vue's list rendering

Table of contents 1. v-for: traverse array conten...

MySQL 8.0.11 Community Green Edition Installation Steps Diagram for Windows

In this tutorial, we use the latest MySQL communi...

How to implement distributed transactions in MySQL XA

Table of contents Preface XA Protocol How to impl...

Linux kernel device driver system call notes

/**************************** * System call******...

Write a shopping mall card coupon using CSS in three steps

Today is 618, and all major shopping malls are ho...

Summary of important components of MySQL InnoDB

Innodb includes the following components 1. innod...

Hello dialog box design experience sharing

"What's wrong?" Unless you are accus...

Introduction to Vue life cycle and detailed explanation of hook functions

Table of contents Vue life cycle introduction and...

Make your text dance with the marquee attribute in HTML

Syntax: <marquee> …</marquee> Using th...

Three ways to communicate between React components (simple and easy to use)

Table of contents 1. Parent-child component commu...

SSH port forwarding to achieve intranet penetration

The machines in our LAN can access the external n...