Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the reason for the invalidation of input type="reset" tags in HTML

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you what is the reason for the invalidation of the input type= "reset" tag in HTML, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.

Using tags, sometimes we will find that the reset button is invalid, and clicking this button will not empty the input box.

Here are the reasons:

The W3C website has this description (http://www.w3school.com.cn/htmldom/dom_obj_reset.asp)

"every time a label appears in a HTML form, a Reset object is 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 property or the defaultValue property of the JavaScript."

This means that if the textarea sets the value of the value property, then the reset button will restore textarea to the value of the value property instead of empty.

The conclusions are as follows:

Instead of emptying the value of the input box, reset restores the value of the input box to the value specified by the value property.

Take a look at the following example. Save the following HTML code as an .html file, open it with a browser, modify the contents of the input box, and click the reset button to see the effect.

But on the results page of the query, we sometimes want the value attribute to have a value (the input condition of the last query), so we can't use the reset tag to achieve the emptying function, notice that it is empty.

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

The above is all the content of the article "what is the reason for the invalidation of the input type=" reset "tag in HTML? thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report