jquery js reset Form reset () __js

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.

<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:

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


Name

Document.formName.reset ();


Method Two:

Empty each:

$ ("#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:

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


The default value for the form. There are other types of forms that are written again.

Add type to reset input

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


$ ("Input[name= ' res ']"). Click ();
    $ ("#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.