返回到:Prototype – 表单管理
此方法查找第一个非隐藏、非禁用的表单控件。
语法
form.findFirstElement();
返回值
它返回 HTMLFormElement。
例子
HTML
x
45
45
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
var element = form.findFirstElement();
10
alert("First non hidden element : " + element.inspect() );
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
</fieldset>
40
</form>
41
<br />
42
43
<input type = "button" value = "Result" onclick = "showResult();"/>
44
</body>
45
</html>
返回到:Prototype – 表单管理
阅读剩余 86%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8523.html