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
WBOYOriginal
2016-05-16 16:38:561452browse

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();

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

<input name="percent" value="50"/>

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');
Statement:
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