Close all modals bootstrap

John

I would like to close all modals with a line of code, I have a code is like this:

closeModals() {

    $('#new-user').modal('hide');
    $('#new-project').modal('hide');
    $('#new-task').modal('hide');
}

But the problem is that I have more than 20 modals in my project, is there a way of closing all modals without repeating the id of each modal ? Thank you !

Natsu

If you can add class to the element you can call just this.

$('.my-modals').modal('hide');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related