<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-8">
<form action="action" method="post">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button> //this submits the form
</div>
<div class="col-4">
<button type="submit" class="btn btn-success">Submit your Post</button> //this is inactive and doesn't submit the form
</div>
</form>
</div>
引导程序的 col 标签工作得很奇怪,提交按钮在类似的意义上不起作用。
<div class="row">
<div class="col-8">
<form action="action" method="post">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button> //this submits the form
</div>
<div class="col-4">
<button type="submit" class="btn btn-success">Submit your Post</button> //this is inactive and doesn't submit the form
</div>
</form>
</div>
您在代码中遗漏了,您需要在<div class="col-8">
之前粘贴此<form action="action" method="post">
标签
试试这个
<div class="row">
<form action="action" method="post">
<div class="col-8">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button> //this submits the form
</div>
<div class="col-4">
<button type="submit" class="btn btn-success">Submit your Post</button> //this is inactive and doesn't submit the form
</div>
</form>
</div>
html close标签是错误的,如果你想提交按钮form
但仍然是表单的一部分,必须这样做:
<div class="row">
<div class="col-8">
<form id="my-form" action="action" method="post">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button> //this submits the form
</form>
</div>
<div class="col-4">
<button type="submit" class="btn btn-success" form="my-form">Submit your Post</button> //this is inactive and doesn't submit the form
</div>
我为表格设置id
<form id="my-form" action="action" method="post">
然后为按钮提交设置form
属性:
<button type="submit" class="btn btn-success" form="my-form">Submit your Post</button>
或者您可以尝试其他方式,如下所示:
<div class="row">
<form action="action" method="post">
<div class="col-8">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button> //this submits the form
</div>
<div class="col-4">
<button type="submit" class="btn btn-success">Submit your Post</button> //this is inactive and doesn't submit the form
</div>
</form>