我正在尝试实现 2 个模态窗口。第一个模式窗口将包括一个联系表格。当用户单击提交时,我希望第一个模态窗口消失,然后立即出现一个新的模态窗口。
在我的情况下,按下提交按钮后,第一个模态消失,第二个模态会短暂出现然后消失。
我确保我只有 bootstrap-modal.js
任何帮助或指导将不胜感激!谢谢
第一个模态
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Contact</h3>
</div>
<div class="modal-body">
<form class="form-horizontal">
<fieldset>
<div class="control-group">
<label class="control-label" for="input01">Name</label>
<div class="controls">
<input type="text" class="input-xlarge" id="input01" name = "name">
</div>
</div>
<div class="control-group">
<label class="control-label" for="input01">E-mail</label>
<div class="controls">
<input type="text" class="input-xlarge" id="input01">
</div>
</div>
<div class="control-group">
<label class="control-label" for="textarea">Message</label>
<div class="controls">
<textarea class="input-xlarge" id="textarea" rows="3"></textarea>
</div>
</div>
</fieldset>
</div>
<div class="modal-footer">
<button id= "form-submit" type="submit" class="btn btn-primary">Send</button>
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
</form>
</div>
第二模态
<div id="messageSentModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Success!</h3>
<p>Your Message has been sent!</p>
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
Javascript
<script src="index_files/jquery.js"></script>
<script src="index_files/bootstrap-transition.js"></script>
<script src="index_files/bootstrap-alert.js"></script>
<script src="index_files/bootstrap-modal.js"></script>
<script src="index_files/bootstrap-dropdown.js"></script>
<script src="index_files/bootstrap-scrollspy.js"></script>
<script src="index_files/bootstrap-tab.js"></script>
<script src="index_files/bootstrap-tooltip.js"></script>
<script src="index_files/bootstrap-popover.js"></script>
<script src="index_files/bootstrap-button.js"></script>
<script src="index_files/bootstrap-collapse.js"></script>
<script src="index_files/bootstrap-carousel.js"></script>
<script src="index_files/bootstrap-typeahead.js"></script>
Javascript自定义代码
a = $(".span4").find('h3'); $(文档).ready(函数() { $(".box").hide(); a.点击(函数(){ $(this).next(".box").slideToggle(600); $(this).removeClass("sub_heading"); }); a.悬停( 功能 () { $(this).addClass("sub_heading"); }, 功能 () { $(this).removeClass("sub_heading"); } ); }); //提交按钮 $("#form-submit").click(function(){ $("#myModal").modal('隐藏'); //隐藏第一个模态 $("#messageSentModal").modal('show'); //显示第二个模态 });