首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

对象模型中对象的引述

2012-06-30 
对象模型中对象的引用通过name属性值引用?form methodpost action nameform1input typetext

对象模型中对象的引用

通过name属性值引用

?

<form method="post" action="" name="form1"><input type="text" name="myname"></form> <script type="text/javascript">  <!--window.document.form1.myname.value='张三';  //-->  </script>

?

?通过数组下标引用

??

<form method="post" action="" name="form1"><input type="text" name="myname"><br><input type="text" name="myname2"></form> <script type="text/javascript">  <!--window.document.forms[0].elements[0].value='张三';window.document.forms[0].elements[1].value='李四';  //-->  </script>

?混合模式:

?

<form method="post" action="" name="form1"><input type="text" name="myname"><br><input type="text" name="myname2"><br><input type="text" name="myname3"></form> <script type="text/javascript">  <!--window.document.form1.myname.value='张三';window.document.forms[0].elements[1].value='李四';window.document.forms[0].myname3.value='myname3';  //-->  </script>

?在上述代码中window和document通常可以被省略

?


热点排行