reset

Like on, reset also accepts a single event action as input.

The only job of this feature is to restore the element's default value.

Custom elements (e.g. Web Components) can also be made resettable; all they must do is implement the standard reset method.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<h4 class="mt0">
  Change the value of the input and click the button to restore it.
</h4>

<form reset="doReset">
  <input
    type="text"
    value="edit me"
    class="input"
  >
</form>

<button
  type="button"
  class="btn mt2"
  on:click="doReset"
>
  click me
</button>

Change the value of the input and click the button to restore it.