`
wsj123
  • 浏览: 149561 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

document.forms用法详解

    博客分类:
  • JS
阅读更多
document.forms用法详解

1.1概述
        document.forms返回一个集合 (一个HTMLCollection对象),包含了当前文档中的所有form元素。
1.2语法
        document.forms:表示获取当前页面的所有表单 元素;
        document.forms[0]:表示获取当前页面的第一个表单元素;
        document.forms['exportServlet']:表示获取当前页面中name="exportServlet"的表单元素;
        document.forms.submit()/document.forms[0].submit()
/document.forms['exportServlet'].submit():表示提交函数。
1.3实例
        实例——获取表单信息并提交。
$(function(){ 
    var thisForm = document.forms[0]; 
    console.info(thisForm.username.value); 
    console.info(thisForm.address.value); 
    document.forms[0].submit();
}) 

<body> 
    <form name="form1" > 
        <input type="text" name="username" value="zhangsan" /> 
        <input type="text" name="address" value="beijing" /> 
    </form> 
    <form name="form2" > </form> 
    <form name="form3" > </form> 
</body>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics