我在bootstrap模式中有一个列表框和一个按钮.单击该按钮时,将在模式中的div内呈现新按钮.当我关闭模态并重新打开它时,在模态上执行的最后一个操作(如前面渲染的按钮)仍然存在于模态中.
如何重置模态,以便当再次打开模态时,按钮不存在,用户可以再次从列表框中选择选项,然后单击按钮以呈现新按钮,依此类推.
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Select Language</h4>
</div>
<div class="modal-body">
<button type="button" class="btn" data-dismiss="modal">Close</button>
<button type="button" class="btn" id="submit_form">Submit</button>
<div class="modal-body1">
<div id="placeholder-div1">
</div>
</div>
</div>
<div class="modal-footer">
<script>
$('#submit_form').on('click', function() {
$(".modal-body1").html('<h3>test</h3>');
});
</script>
<script>
$(function(){
$('.modal-footer').click(function() {
$('.modal').modal('hide');
});
});
</script>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
- 更新---
为什么这不起作用?
<script type="text/javascript">
$(function(){
$('#myModal').on('hidden.bs.modal', function (e) {
console.log("Modal hidden"); …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来清除Bootstrap模式中包含的HTML表单中找到的所有元素,而无需刷新页面.
目前:
用户输入数据并关闭模态.
当用户重新打开模态时,先前输入的数据仍然存在.
如何在模式对话框的关闭事件期间完全清除表单中的所有元素,以便当用户重新打开它时,它们总是获得新鲜的干净输入等?
我的网页上有一个iframe视频列表.
<iframe width="520" height="360" src="http://www.youtube.com/embed/2muxrT5_a6E" frameborder="0" allowfullscreen></iframe>
<iframe width="520" height="360" src="http://www.youtube.com/embed/2muxrT5_a6E" frameborder="0" allowfullscreen></iframe>
<iframe width="520" height="360" src="http://www.youtube.com/embed/2muxrT5_a6E" frameborder="0" allowfullscreen></iframe>
<a href="#" class="close">Stop all videos</a>
Run Code Online (Sandbox Code Playgroud)
我需要点击链接停止所有播放iframe视频Stop all videos.我怎样才能做到这一点?