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