我有提交按钮的表单。用户点击“提交”后,我希望在按钮旁边显示Record Successfully saved
之类的消息。以下是我的表格示例:
<form name="frm_myaccount" id="frm_myaccount" class="frm-Submit" autocomplete="off">
<div class="form-group required">
<label class="control-label" for="answer">Answer</label>
<input type="text" class="form-control" name="frm_answer" id="frm_answer" placeholder="Enter Answer" maxlength="100" required>
</div>
<div>
<div class="col-xs-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
<div class="col-xs-10">
<div id="myaccount-message" class="alert"></div>
</div>
</div>
</form>
上面的代码移动了表格网格之外的提交按钮。我想知道在表单中是否有任何类在同一网格中将元素组合在一起?
答案 0 :(得分:1)
&#34;在表单网格外提交按钮&#34;
它仍在表单网格中,但只有15px
问题
您已将button
课程col-*-2
提供给margin:15px
col-*-2
form-group
inline-block
.alert
$('#frm_myaccount').submit(function(e) {
$('#myaccount-message').append("<p style='line-height:0px; color:green; font-weight:700;'>Submit Recorded Successfully!</p>");
e.preventDefault();
});
&#13;
.alert {
padding: 0px !important;
}
&#13;
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.3/js/bootstrap.js"></script>
<form name="frm_myaccount" id="frm_myaccount" class="frm-Submit" autocomplete="off">
<div class="form-group required">
<label class="control-label" for="answer">Answer</label>
<input type="text" class="form-control" name="frm_answer" id="frm_answer" placeholder="Enter Answer" maxlength="100" required>
</div>
<div class="form-group">
<button style="display:inline;" type="submit" id="forrm" class="btn btn-primary">Submit</button>
<div style="display:inline-block;" id="myaccount-message" class="alert"></div>
</div>
</form>
&#13;