表返回到:Prototype – 表单管理
此方法启用完全或部分禁用的表单。启用表单是通过遍历表单元素并启用它们来完成的。
语法
form.enable();
返回值
它返回 HTMLFormElement。
例子
HTML
x
46
46
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function showResult() {
8
var form = $('example');
9
form[form.disabled ? 'enable' : 'disable']();
10
form.disabled = !form.disabled;
11
}
12
</script>
13
</head>
14
15
<body>
16
<p>Click the button to see the result.</p>
17
<br />
18
19
<form id = "example" action = "#" onsubmit = "return false">
20
<fieldset>
21
<legend>User info</legend>
22
<div>
23
<label for = "username">Username:</label>
24
<input name = "username" id = "username" value = "Sulien" type = "text">
25
</div>
26
<div>
27
<label for = "age">Age:</label>
28
<input name = "age" id = "age" value = "23" size = "3" type = "text">
29
</div>
30
<div>
31
<label for = "hobbies">Your hobbies are:</label>
32
<select name = "hobbies" id = "hobbies" multiple = "multiple">
33
<option>coding</option>
34
<option>swimming</option>
35
<option>hiking</option>
36
<option>drawing</option>
37
</select>
38
</div>
39
<div class = "buttonrow">
40
<button onclick = "showResult();">Toggle disabled!</button>
41
</div>
42
</fieldset>
43
</form>
44
45
</body>
46
</html>
返回到:Prototype – 表单管理
阅读剩余 86%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8526.html