简体   繁体   English

单击链接以关闭模态后使用jquery做某事

[英]Do something with jquery after clicking a link to close a modal

I have a modal with the following code to close it 我有一个模态与以下代码将其关闭

a#modalclick.icon.icon-close.pull-left href="#mymodal"

I want to know when the x icon is clicked and the modal closed so I can do something with the link id. 我想知道何时单击x图标并关闭模态,以便可以使用链接ID进行操作。

My javascript is; 我的JavaScript是;

$('#modalclick').on('click', function(event) {
  console.log('clicked')
});

but it's not recognising the modal being clicked closed... 但它无法识别正在关闭的模式...

use these events hidden.bs.modal , hide.bs.modal Docs . 使用这些事件hidden.bs.modalhide.bs.modal 文档

JS JS

$('#mymodal').on('hidden.bs.modal', function(event) {
console.log('modal is being to be closed')
});
$('#mymodal').on('hide.bs.modal', function(event) {
console.log('modal hidden')
});

Have you tried using .not(':visible') ? 您是否尝试使用.not(':visible')?

if ( $('#yourdiv').not(':visible') ) {
  console.log('not visible');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM