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

How to implement DIV's blur function

Use anti-shake to make DIV disappear when the mou...

The whole process of node.js using express to automatically build the project

1. Install the express library and generator Open...

Ideas for creating wave effects with CSS

Previously, I introduced several ways to achieve ...

mysql uses stored procedures to implement tree node acquisition method

As shown in the figure: Table Data For such a tre...

Introduction to Vue life cycle and detailed explanation of hook functions

Table of contents Vue life cycle introduction and...

7 native JS error types you should know

Table of contents Overview 1. RangeError 2. Refer...

Two ways to make IE6 display PNG-24 format images normally

Method 1: Please add the following code after <...

Solve the abnormal error when building vue environment with webpack

Table of contents First, configure package.json T...

Solve the problem that the time zone cannot be set in Linux environment

When changing the time zone under Linux, it is al...

Use Docker to run multiple PHP versions on the server

PHP7 has been out for quite some time, and it is ...

Additional instructions for using getters and actions in Vuex

Preliminary Notes 1.Differences between Vue2.x an...

What does the "a" in rgba mean? CSS RGBA Color Guide

RGBA is a CSS color that can set color value and ...