`

document.getElementsByTagName

阅读更多
http://www.w3school.com.cn/htmldom/met_doc_getelementsbytagname.asp
<html>
<head>
<script type="text/javascript">
function getElements()
  {
  var x=document.getElementsByTagName("input");
  alert(x);
  alert(x[0].value);
  alert(x[0].name + " " + x[1].name + " " + x[2].name);
  }
</script>
</head>
<body>

<input name="myInput1" type="text" size="20" value="hehe"/><br />
<input name="myInput2" type="text" size="20" /><br />
<input name="myInput3" type="text" size="20" /><br />
<br />
<input type="button" onclick="getElements()" value="How many input elements?" />

</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics