jquery js reset form reset () specific implementation code _jquery

Source: Internet
Author: User
In development, we will use a lot of forms, we want to submit the form after the reset,
But jquery does not have this method, how to deal with it?
Copy Code code as follows:

<form id= "Form1" action= "method=" POST "runat=" Server ">
<input name= "INP" id= "INP" value= "1"/>
</form>

Method One:
We can do this by just realizing
Id:
Copy Code code as follows:

document.getElementById ("Form1"). Reset ();

Name
Copy Code code as follows:

Document.formName.reset ();

Method Two:
Empty each:
Copy Code code as follows:

$ ("#inp"). Val ("1");

But the form is too many words, this is also impractical, there are 100, 1000, can not write 100, 1000.
Perhaps you would say, written like this:
Copy Code code as follows:

$ ("input"). Val ("");

What about the default value of the form? What other types of forms do you write?
Add type to reset input
Copy Code code as follows:

<form id= "Form1" action= "method=" POST "runat=" Server ">
<input name= "INP" id= "INP" value= "1"/>
<input id= "res" name= "res" type= "reset" style= "Display:none"/>
</form>

Copy Code code as follows:

$ ("Input[name= ' res ']"). Click ();

All Forms Empty
Ok

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.