form表单重置、清空⽅法记录myform 是form的id属性值
1.调⽤reset()⽅法
1function fomrReset()
2 {
3    ElementById("myform").reset();
4 }
2. 逐个清空input、select值
1function resetAll() {
2    $("#myform").find('input[type=text],select,input[type=hidden]').each(function() {
3        $(this).val('');
4    });
5 }
3.排除法清空form表单
1<!DOCTYPE html>
2<html>
3
4<head>
5<meta charset="UTF-8">
6<title>form表单重置</title>
html input type属性7<script src="login/js/jquery-1.4.2.min.js"></script>
8</head>
9
10<body>
11<form action="" method="post" id="myform">
12<label for="name">姓名:</label>
13<input type="text" name="name" id="name" value="" placeholder="请输⼊名字"/>
14<label>性别:</label>
15<input type="radio" name="sex" checked value=""/>男
16<input type="radio" name="sex" value=""/>⼥
17</form>
18<input type="button" name="" value="重置" onclick="formReset()"/>
19<script type="text/javascript">
20function formReset() {
21                $(':input', '#myform')
22                    .not(':button, :submit, :reset, :hidden,:radio') // 去除不需要重置的input类型
23                    .val('')
24                    .removeAttr('checked')
25                    .removeAttr('selected');
26            }
27</script>
28</body>
29
30</html>