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 !
If you can add class to the element you can call just this.
$('.my-modals').modal('hide');