大家好,又见面了,我是全栈君。
// modal所在的html 的<body>标签前面加上
$(function(){
$('#myModal').on('hide.bs.modal', function (e) {
$("#myModal .modal-body").empty();
});
});
<!-- modal 右上角的“X” 添加onclick触发事件的方法 -->
<div class="modal fade" id="myModal" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document" style="width:80%">
<div class="modal-content
<div class="modal-header">
<button type="button" class="close" onclick="calloff()" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">标题</h4>
</div>
<div class="modal-body" id="myModalBody"></div>
</div>
</div>
</div>
//onclick 方法的具体实现,右上角的“X”和“关闭”按钮均调用这个
calloff:function(){
$("#myModal").modal("hide");
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/120873.html原文链接:https://javaforall.cn
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有