Jim Jim - 1 year ago 71
Javascript Question

How to reset forms elements (input,select,textarea,etc.) on events using jQuery

I need to reset forms elements after click span for example.

Is there a method to reset the from by jQuery without select each element and remove the attribute value.

Some of the elements not having attribute value like textarea or radio

And some like button I don't want to remove the value from it.

I want use jQuery to use the reset on other events

Code for example http://jsfiddle.net/pgNrF/

<input type="button" value="Input Button">
<input type="checkbox">
<input type="hidden">

Answer Source

This is already built in if you wrap those form elements in an actual form:

<form id="myform">  
    <input type="button" value="Input Button">
    <input type="checkbox">
    <input type="file">
    <input type="hidden">
    <input type="image">
    <input type="password">
    <input type="radio">
    <input type="submit">
    <input type="text">

    <button type="button">Button</button> 

    <button type="reset">Reset</span>


If you just have to use jQuery:

$('span').click(function() {


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download