javascript取得表單對(duì)象的幾種方法
<html><head></head>
<body>
<form name="fm1" id="fm1">
name:<input type="text" name="name" id="name1" />
<input type="submit" id="s1"/>
</form>
<form name="fm2" id="fm2">
name:<input type="text" name="name" id="name2" />
<input type="submit" id="s2" />
</form>
<script type="text/javascript">
//var form = document.getElementById('fm2');
//var formarray = document.forms[1];//得到頁面中所以表單的數(shù)組
//var form = document.forms['fm1'];//根據(jù)表單name屬性得到數(shù)組
var form = document.fm1;//根據(jù)表單name屬性得到數(shù)組
alert(form);
</script>
</body>
</html>
posted on 2013-06-27 16:23 楊軍威 閱讀(4473) 評(píng)論(0) 編輯 收藏