Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

People also ask

How do you reset input field in form?

To clear all the input in an HTML form, use the <input> tag with the type attribute as reset.

How we can reset form in jQuery?

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).

How do you reset a form element?

The HTMLFormElement. reset() method restores a form element's default values. This method does the same thing as clicking the form's <input type="reset"> control. If a form control (such as a reset button) has a name or id of reset it will mask the form's reset method.

What is reset in jQuery?

Definition and Usage. The :reset selector selects button and input elements with type=reset. Tip: Using input:reset as a selector will not select the button element.


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">
<textarea></textarea>
<span>Reset</span>