返回到:Prototype – 表单管理
此方法将表单重置为其默认值。
语法
formElement.reset();
返回值
它返回一个 HTMLFormElement。
例子
考虑以下示例
HTML
x
44
44
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function resetIt() {
8
var form = $('example');
9
form.reset();
10
}
11
</script>
12
</head>
13
14
<body>
15
<p>Type something and click the button to see the result.</p>
16
<br />
17
18
<form id = "example" action = "#" onsubmit = "return false">
19
<fieldset>
20
<legend>User info</legend>
21
<div>
22
<label for = "username">Username:</label>
23
<input name = "username" id = "username" value = "Sulien" type = "text">
24
</div>
25
<div>
26
<label for = "age">Age:</label>
27
<input name = "age" id = "age" value = "23" size = "3" type = "text">
28
</div>
29
<div>
30
<label for = "hobbies">Your hobbies are:</label>
31
<select name = "hobbies" id = "hobbies" multiple = "multiple">
32
<option>coding</option>
33
<option>swimming</option>
34
<option>hiking</option>
35
<option>drawing</option>
36
</select>
37
</div>
38
</fieldset>
39
</form>
40
<br />
41
42
<input type = "button" value = "Reset It" onclick = "resetIt();"/>
43
</body>
44
</html>
返回到:Prototype – 表单管理
阅读剩余 58%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8503.html