xhuang 发表于 2013-2-7 20:36:18

HTML 5 form属性支持

<form id="contact_form" method="get">    <p>      <label for="name">姓名:</label><input type="text" id="name" name="name">    </p>    <p>      <label for="email">邮箱:</label><input type="email" id="email" name="email">    </p>    <input type="submit" id="submit" value="发送">    <a href="html5-new-form-attribute.html" class="reload">重载当前页</a></form><p>    评论:<textarea id="comments" name="comment" form="contact_form [空格传多个id,可以被多个form使用]"></textarea></p>HTML5中的form属性可以让HTML控件元素孤立在表单之外,然后表单在提交的时候不仅可以提交表单内的控件元素,这个孤立在外的控件元素值也可以一并提交出去
 
转自:http://www.zhangxinxu.com/wordpress/?p=1715
demo: http://www.zhangxinxu.com/study/201106/html5-new-form-attribute.html
 
 
 
 
<form action="demo_form.asp" method="get" id="user_form">First name:<input type="text" name="fname" /><input type="submit" /></form><form action="demo_form.asp" method="get" id="user_form_2">First name:<input type="text" name="fname2" form="user_form" /><input type="submit" /></form> input元素,定义form属性是user_form, 但自己被wrap在user_form_2中。此时如果点击user_form中的提交按钮,input元素一并提交,但当点击user_form_2中提交按钮,则提交内容为空
 
总结:当input定义了form属性,则不管他在那,或是在form内,或是独立于form,他只是属于form属性指定的form元素!!!
 
注: 好文章,烂笔头,好记忆
 
页: [1]
查看完整版本: HTML 5 form属性支持