0

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.

My javascript is;

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

but it's not recognising the modal being clicked closed...

raphael_turtle
  • 7,154
  • 10
  • 55
  • 89

2 Answers2

0

use these events hidden.bs.modal, hide.bs.modal Docs.

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')
});
J Santosh
  • 3,808
  • 2
  • 22
  • 43
-1

Have you tried using .not(':visible') ?

if ( $('#yourdiv').not(':visible') ) {
  console.log('not visible');
}
amespower
  • 907
  • 1
  • 11
  • 25