It should be $(this).reset();
But since your using an id in the selector, that will reset only the
particular form you want.
If you wish to reset all the forms in the page you should do something
similar to this :

$('form').each(function(){
   $(this).reset();
});

You should of course put this piece of code in the document ready function.

Thanks & Regards,
Dhruva Sagar.


Pablo Picasso<http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html>
- "Computers are useless. They can only give you answers."

On Wed, Sep 16, 2009 at 1:45 PM, pritisolanki <pritiatw...@gmail.com> wrote:

>
> Hi,
>
> I am trying to reset all the form element but it is not working can
> someone suggest the reason.
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html;
> charset=ISO-8859-1" />
> <title>jQuery Starterkit</title>
>
> <link rel="stylesheet" type="text/css" media="screen"
> href="screen.css" />
> <script src="jquery-1.3.2.min.js" type="text/javascript"></script>
> <script src="custom.js" type="text/javascript"></script>
> </head>
> <body>
> <SCRIPT LANGUAGE="JavaScript">
> <!--
> $(document).ready(function() {
>
>   $("#reset").click(function() {
>     $("form").each(function() {
>       this.reset();
>     });
>   });
>
>
> });
>
> //-->
> </SCRIPT>
>
> <h1>jQuery Starterkit</h1>
> <h2>This page contains code to test the examples. Most of it is only
> relevant for a example.</h2>
>
> <a id="first" href="#">Some link</a>
> <br/><br/><hr/>
> <p>
> <p style="visibility:display">Hehehehe so think you can hide me :-p </
> p>
> </p>
> <br/><br/><hr/>
>        <form id="form" name="form1">
>                Form 1
>                <input name="foo" value="XXX" />
>        </form>
>
>        <form id="form" name="form2">
>                Form 2
>                <input name="bar" value="YYY" />
>        </form>
>
>        <form id="form" name="form3">
>                Form 3
>                <input type="checkbox" />
>                <input type="checkbox" checked="checked" />
>        </form>
> <br/><br/><hr/>
>        <a id="reset" href="#">Reset!</a>
>
> </body>
> </html>
>

Reply via email to