How to reset a form using jQuery with .reset() method?

Reset gets anything back to its original state. JQuery doesn’t have a reset() method, but native JavaScript does. So, we convert the jQuery element to a JavaScript object.

JavaScript reset(): The reset() method resets the values of all elements in a form (same as clicking the Reset button).

    Syntax for JavaScript reset button:

  • // type-1
    <input type="reset">
  • // type-2
    <input type="button" onclick="this.form.reset();">
  • // type-3
    <input type="button" onclick="formname.reset();">

The button itself resets the form but, the type-1 and type-2, the reset button should be inside the form and type-3 can be either out or in.
But a reset button is a far better choice. (type-1)

  • <input type="reset">
  • Syntax for reset():
  • Syntax to convert jQuery element to a JavaScript object.



If we don’t want to convert the jQuery element to a JavaScript object then we can use the trigger().

As trigger() method triggers the specified event and the default behavior of an event (like form submission) for the selected elements.

$(selector).trigger(event, eventObj, ...)






<!DOCTYPE html>
    <title>Try jQuery Online</title>
    <script src=
        $(document).ready(function() {
            $("button").click(function() {
        <h1 style="color:green">GeeksforGeeks</h1>
        Click on "Submit" to submit and 
          remaining resets to get form to original state. 
        <form id="d" action="/cgi-bin/test.cgi" name="geek">
            <table cellspacing="0" cellpadding="3" border="1">
                    <td align="center">Username</td>
                        <input type="text" name="name" />
                    <td align="center">Email</td>
                        <input type="text" name="name" />
                    <td align="center">Password</td>
                        <input type="password" />
                    <td align="center"></td>
                        <input type="submit" value="Submit" />
                    <td align="center"></td>
                        <input type="reset" value="reset button" />
        <input type="button" 
               value="reset() outside form" 
               onclick="geek.reset();" />
        <button>resetby jQuery</button>



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.