document.forms对象

来源:互联网 发布:深度linux deepin2016 编辑:程序博客网 时间:2024/06/05 17:00
document.forms,返回一个集合,包含页面所有form元素<!doctype html><html lang="en"> <head>  <meta charset="UTF-8">  <title>Document</title>  <script src="../jquery/jquery-1.10.2.min.js"></script><script type="text/javascript">function doSubmit(){var name=document.forms["form1"].name.value;//name为form1的,input name为name的var password = document.forms[0].password.value;//第一个form表单,input name为password的alert(name+"   "+password);document.forms["form1"].submit();//提交}</script> </head> <body><form name="form1" action="#" method="get"><input type="text" name="name" value="aaa"/><input type="text" name="password" value="bbb"/><input type="button" name="提交" value="提交" onclick="doSubmit()"/></form> </body></html>


原创粉丝点击