Empty FORM element code instance implemented using jquery

Source: Internet
Author: User

Empty FORM element code instance implemented using jquery:
If the elements of the form are more, if you want to fill in the situation before the content may be a bit of energy-intensive, not humane, the following describes how to use jquery code to quickly clear the content of the form elements of the function, first look at a code example:

$ (' #theform ') [0].reset ();

A friend may think that the above code will fully implement our requirements, in fact, this is wrong, reset () function is the meaning of reset, that is, the value of the form element is reset to the default value instead of emptying, such as the following text box:

<type= "text"  value= "Ant tribe"/>

The value in the above text box is reset to "Ant tribe" instead of emptying, so the code is modified as follows:

$ (': input ', ' #theform '). Not (': Button,:submit,:reset,:hidden ').val ('). Removeattr (' Checked '). Removeattr (' selected ');

The above code is the implementation of our requirements, the code is very simple, there is not much to introduce, you can see the relevant reading.
Related reading:
The 1.not () function can be found in the Not () method section of jquery .
The 2.removeAttr () function can be found in the Removeattr () method section of jquery .
The 3.val () function can be found in the section of the Val () method of jquery .

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=15272

For more information, refer to: http://www.softwhy.com/jquery/

Empty FORM element code instance implemented using jquery

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.