Bootstrap Modal對(duì)話框如何在關(guān)閉時(shí)觸發(fā)事件
下表列出了模態(tài)框中要用到事件。這些事件可在函數(shù)中當(dāng)鉤子使用。

實(shí)例
下面的實(shí)例演示了事件的用法:
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 實(shí)例 - 模態(tài)框(Modal)插件事件</title>
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="/scripts/jquery.min.js"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<h2>模態(tài)框(Modal)插件事件</h2>
<!-- 按鈕觸發(fā)模態(tài)框 -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
開始演示模態(tài)框
</button>
<!-- 模態(tài)框(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"
aria-hidden="true">×
</button>
<h4 class="modal-title" id="myModalLabel">
模態(tài)框(Modal)標(biāo)題
</h4>
</div>
<div class="modal-body">
點(diǎn)擊關(guān)閉按鈕檢查事件功能。
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">
關(guān)閉
</button>
<button type="button" class="btn btn-primary">
提交更改
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
$(function () { $('#myModal').modal('hide')})});
</script>
<script>
$(function () { $('#myModal').on('hide.bs.modal', function () {
alert('嘿,我聽說您喜歡模態(tài)框...');})
});
</script>
</body>
</html>

更多內(nèi)容請(qǐng)點(diǎn)擊專題《Bootstrap Modal使用教程》進(jìn)行學(xué)習(xí),希望大家喜歡。
如果大家還想深入學(xué)習(xí),可以點(diǎn)擊這里進(jìn)行學(xué)習(xí),再為大家附3個(gè)精彩的專題:
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
如何在js代碼中消滅for循環(huán)實(shí)例詳解
for循環(huán)對(duì)大家來說都不陌生,下面這篇文章主要給大家介紹了關(guān)于如何在js代碼中消滅for循環(huán)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-07-07
arctext.js實(shí)現(xiàn)文字平滑彎曲弧形效果的插件
這篇文章主要介紹了arctext.js實(shí)現(xiàn)文字平滑彎曲弧形效果的插件,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05
JavaScript實(shí)現(xiàn)連連看連線算法
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)連連看連線算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-01-01
原生JavaScript中直接觸發(fā)事件的方式小結(jié)
JavaScript提供了多種方式來直接觸發(fā)事件,無論是在用戶交互、程序邏輯處理或是數(shù)據(jù)更新時(shí),本文將全面探討原生JavaScript中各種事件觸發(fā)方式,并通過深入的技術(shù)案例分析,需要的朋友可以參考下2025-01-01

