当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > HTML DOM elements 集合

HTML DOM
DOM TableRow 对象
DOM Textarea 对象
DOM Window 对象

HTML DOM elements 集合


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 404 ::
收藏到网摘: n/a

Definition and Usage
定义与用法

The elements collection returns an array containing each element in the form.
元素集合可返回在包含了表单中每个元素的数组

Syntax
语法

formObject.elements[].property


Example
举例

The following example outputs the value of all the form elements:
下面的举例将输出所有表单中的元素:

<html>
<body>
<form id="myForm">
Firstname: <input id="fname" type="text" value="Mickey" />
Lastname: <input id="lname" type="text" value="Mouse" />
<input id="sub" type="button" value="Submit" />
</form>
<p>得到表单中所有元素的值:<br />
<script type="text/javascript">
var x=document.getElementById("myForm");
for (var i=0;i<x.length;i++)
{
document.write(x.elements[i].value);
document.write("<br />");
}
</script>
</p>
</body>
</html>


演练

Get the value of all form elements
得到所有表单中元素的值

评论 (0) All

登陆 | 还没注册?