$("#myModal").modal()
$('#code').on('shown.bs.modal', function (e) {
// do something...
})
//This event fires immediately when the show instance method is called.
$('#myModal').on('show.bs.modal', function (e) {
// do something...
});
//This event is fired when the modal has been made visible to the user
$('#myModal').on('shown.bs.modal', function (e) {
// do something...
});
//This event is fired immediately when the hide instance method has been called.
$('#myModal').on('hide.bs.modal', function (e) {
// do something...
});
//This event is fired when the modal has finished being hidden
$('#myModal').on('hidden.bs.modal', function (e) {
// do something...
})
// Hide current modal before opening new one
$("#idModal").modal('hide');
$("#idModal2").modal() // or .modal("show");
// show 1st modal again after closing 2nd modal
$("#idModal2").on('hidden.bs.modal', () => $("#idModal").modal('show'))
// using hide.bs.modal might cause modal to stop scrolling!!!
let el = document.getElementById("modal1");
new Modal(el).show();