Reset button tip-Why cannot I reset the form data? tip form
When I first learned html, some people may encounter a problem, that is, why does the reset button in the editing Page always fail to work and data is not cleared? Next, let's explain the reason.
Reset object
The Reset object represents a Reset button in the HTML form.
Each time a <input type = "reset"> tag appears in an 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 theirDefault Value. The default value is specified by the HTML value Attribute or the defaultValue attribute of JavaScript.
The reset button triggers the onclick handle before the form is reset, And the handle can be canceled by returning fasle.
See the Form. reset () method and Form. onreset event handle.
You can access a reset button by traversing the elements [] array of the form, or by using document. getElementById ().
Important
It is the default value mentioned above. As the name suggests, the editing page is the page that has already filled in the data, which contains the default data filled in before, that is to say, there is a default value in the input box, but it is not empty data as before, so when you click the reset button, it will only return to the default value you entered for the first time, data is not cleared.
Ps: At the beginning, I also encountered this problem, which was hard to understand. Hope to help the comrades who are learning the same issues as me.