//ByName获取
var names = document.getElementsByName("name");
alert(names[0].value);
//byTagName也是一样的,返回数组和长度
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>document</title>
<script type="text/javascript">
function fun(){
var nodes = document.getElementsByTagName("a");
alert(nodes.length);
nodes[0].target = "http://www.csdn.net/";
alert(nodes[0].innerHTML);
}
</script>
</head>
<body>
<input type="button" value="演示DOM" οnclick="fun()">
<a href="http://www.baidu.com">寻他千百度</a>
</body>
</html>