Open In App
Related Articles

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

Improve Article
Save Article
Like Article

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>


jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.
You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 03 Aug, 2021
Like Article
Save Article
Similar Reads
Complete Tutorials