Home > Web Front-end > JS Tutorial > New understanding of Form reset method_javascript skills

New understanding of Form reset method_javascript skills

WBOY
Release: 2016-05-16 16:56:46
Original
1645 people have browsed it

The reset method of the Form form in HTML is used to clear the content entered by the user. It has been mistakenly thought that it simply clears the values ​​​​in input items such as input.

But this is not actually the case. The essence of the reset method is to restore the content in input items such as input to the value in the attribute value, not the "" null value.

W3c says this:

In an HTML form, every time the tag appears, a Reset object will be created.

When the reset button is clicked, the values ​​of all input elements in the form containing it are reset to their default values. The default value is specified by the HTML value attribute or JavaScript's defaultValue attribute.

In actual situations, we often need to implement form reset when editing certain content, but at this time the value attribute of input items such as input may have been assigned a value, so reset just initializes the form to this value.

In this case, we can only use javascript to set the value attribute of input items such as input to empty to achieve the reset effect.

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