无法跨越多个div的表单 [英] Can't span form over multiple divs

查看:89
本文介绍了无法跨越多个div的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论何时我使用< / form> 通过< code>< / div> ,浏览器(chrome& firefox至少)关闭< form> 标记。下面是示例代码

 < div class =modal-body> 
< form method =postaction =/ api / users />
< textarea name =description>
< / textarea>
< / div>
< div class =modal-footer>
< input type =submitclass =btn btn-primaryvalue =Submit/>
< / form>
< / div>

以下是小提琴

解决方案

它不是有效的HTML。

如果您想跨越多个< div> 的表单,您需要将表单

 < form method =postaction =/ api / users /> 
< div class =modal-body>
< textarea name =description>
< / textarea>
< / div>
< div class =modal-footer>
< input type =submitclass =btn btn-primaryvalue =Submit/>
< / div>
< / form>


Whenever I use a <form> that's separated by the closing </form> via a </div>, the browser (chrome & firefox at least) closes the <form> tag. Below is the sample code

<div class="modal-body">
  <form method="post" action="/api/users/">
    <textarea name="description">
    </textarea>
</div>
<div class="modal-footer">
  <input type="submit" class="btn btn-primary" value="Submit" />
  </form>
</div>

Here is the fiddle

解决方案

You can't do it the way you show; it's not valid HTML.

If you want to span the form across multiple <div>'s, you need to put the form tag outside them:

<form method="post" action="/api/users/">
  <div class="modal-body">
    <textarea name="description">
    </textarea>
  </div>
  <div class="modal-footer">
   <input type="submit" class="btn btn-primary" value="Submit" />
  </div>
</form>

这篇关于无法跨越多个div的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆