Home >Web Front-end >Bootstrap Tutorial >How to close event in bootstrap modal box
The modal box avoids clicking on the background to close:
1. Add the attribute aria-hidden="true" data-backdrop="static"## when the div is initialized. #
<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden='true' data-backdrop='static'>2. When you need to display the modal box during initialization
$(‘#myModal').modal({ backdrop: ‘static', //点击背景空白处不被关闭; keyboard: false //触发键盘esc事件时不关闭。 });Related recommendations: "
bootstrap Getting Started Tutorial"
Customize the modal box display and Close trigger event:$(".classname").click(function () { $('#mymodel').modal('show'); alert('模态框打开了'); }); $('#mymodel').on('hide.bs.modal', function () { alert('模态框关闭了'); });
The above is the detailed content of How to close event in bootstrap modal box. For more information, please follow other related articles on the PHP Chinese website!