Home > Web Front-end > JS Tutorial > There are too many fields. jquey method to quickly clear the form content_jquery

There are too many fields. jquey method to quickly clear the form content_jquery

WBOY
Release: 2016-05-16 16:38:56
Original
1466 people have browsed it

I made a complex query page with too many fields. It was very troublesome to fill it in once and clear it out

$('#myform')[0].reset();
Copy after login

Although the reset method can do part of it, if you have an element like this

<input name="percent" value="50"/>
Copy after login

Then clicking reset will only restore it to 50

So, with the following method, browse online,

$(':input','#myform') 
.not(':button, :submit, :reset, :hidden') 
.val('') 
.removeAttr('checked') 
.removeAttr('selected');
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template