Reputation: 37856
I am trying to write a code which enables one to close the open bootstrap modals once you hit the enter key.
this is my code:
$(document).keyup(function(e) {
if(e.keyCode==13){
if(!$(e.target).closest('.modal fade in').length) {
$('.modal').each(function(){
$(this.previousSibling).modal('hide');
});
}
}
});
please help, what am i doing wrong?
Upvotes: 0
Views: 4493
Reputation: 37856
I did simply:
$('.modal').modal('hide');
and all open modals closed.
what the heck! :D
Upvotes: 2