gpt4 book ai didi

twitter-bootstrap - 在 Bootstrap Modal 上捕获关闭事件

转载 作者:行者123 更新时间:2023-12-03 05:45:04 27 4
gpt4 key购买 nike

我有一个 Bootstrap 模态来选择事件。如果用户单击 X 按钮或模式之外,我想将它们发送到默认事件。我如何捕获这些事件?

这是我的 HTML 代码:

<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content event-selector">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<center><h1 class="modal-title event-selector-text">Select an Event</h1><center>
</div>
<div class="container"></div>
<div class="modal-body">
<div class="event-banner">
<a href="/?event=1">
<img src="<?php echo IMAGES_EVENT1_LOGO; ?>" width="100%">
</a>
</div>
<div class="event-banner">
<a href="/?event=2">
<img src="<?php echo IMAGES_EVENT2_LOGO; ?>" width="100%">
</a>
</div>
</div>
</div>
</div>
</div>

最佳答案

这与另一篇 stackoverflow 文章非常相似, Bind a function to Twitter Bootstrap Modal Close 。假设您使用的是 Bootstap v3 或 v4 的某个版本,您可以执行以下操作:

$("#myModal").on("hidden.bs.modal", function () {
// put your default event here
});

关于twitter-bootstrap - 在 Bootstrap Modal 上捕获关闭事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30298041/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com