我在主页上有一个欢迎类型的 bootstrap-modal,它显示了三个按钮,每个按钮都应该加载不同的页面
这是 HTML 的相关摘录
<div class="modal fade" id="welcomeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
<div class="modal-dialog" >
<div class="modal-content" ;">
<div class="modal-header">
<h3 class="modal-title" id="ModalLabel">Welcome to Here</h3>
</div>
<div class="modal-body" style='height: 90.5%;'>
<span style="display:td;text-align;center;">Blah Blah BLah</span>
</div>
<div class="modal-footer">
<div class="btn-group">
<a id='taketour' class="btn btn-default btn-lg" data-dismiss="modal" ,aria-hidden="true" href="/tour">Take a tour</a>
<a id='register' class="btn btn-default btn-lg" data-dismiss="modal" aria-hidden="true" href="/add">Register</a>
<a id='login' class="btn btn-default btn-lg" data-dismiss="modal" aria-hidden="true" href="/login">Login</a>
</div>
</div>
</div>
</div>
</div
这里是我的 JS
$(window).load(function(){
$('#welcomeModal').modal('show');
});
$('#welcomeModal').on('hidden.bs.modal', function (e) {
if (e.id == 'taketour') {
$(window).location=e.href;
}
if (e.id == 'login') {
$('#welomeModal').remote='element-login';
}
});
(注意:这个JS显然不起作用。这只是我的最后一次尝试)
所以,问题是:我怎样才能从 中找到哪个按钮被按下了?内
hidden.modal.bs
功能?
最佳答案
而不是 hidden.bs.modal
,看看hide.bs.modal
,在对话框关闭之前触发。
与其看 e,不如试试看 document.activeElement
(如 document.activeElement.innerText
或 document.activeElement.id
)。
关于events - Bootstrap 如何检测哪个按钮关闭了 'hidden_modal_bs' 事件函数上的模式对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23169953/