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

HTML DOM
DOM 介绍
HTML DOM 举例
DOM 参考
DOM 摘要
HTML DOM 实例
DOM Anchor
DOM Applet
DOM Area
DOM Base 对象
DOM Basefont对象
DOM Body 对象
DOM Document 对象
DOM 事件
DOM Form 对象
DOM Frame 对象
DOM Frameset 对象
DOM History
DOM Iframe 对象
DOM Image 对象
HTML DOM Button对象

HTML DOM elements 集合


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 402 ::
收藏到网摘: 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

登陆 | 还没注册?