Открытие нового модального окна с закрытием предыдущего
Всем привет пишу код на чистом html css jquery. Хочу чтоб при открытии второго модального окна закрывалось первое.
const modalCall = $('[data-modal]');
const modalClose = $('[data-close]');
modalCall.on("click", function(event) {
event.preventDefault();
let $this = $(this);
let modalId = $this.data('modal');
$(modalId).addClass('show');
$('.slick-slider').slick('setPosition');
$('body').addClass('no-scroll');
setTimeout(function() {
$(modalId).find('.modal__dialog').css({
transform: 'rotateX(0)'
});
}, 200);
});
modalClose.on("click", function(event) {
event.preventDefault();
let $this = $(this);
let modalParent = $this.parents('.modal');
modalParent.find('.modal__dialog').css({
transform: 'rotateX(90deg)'
});
setTimeout(function() {
(modalParent).removeClass('show');
$('body').removeClass('no-scroll');
}, 200);
});
$('.modal').on("click", function(event) {
let $this = $(this);
$this.find('.modal__dialog').css({
transform: 'rotateX(90deg)'
});
setTimeout(function() {
$this.removeClass('show');
$('body').removeClass('no-scroll');
}, 200);
worksSlider.slick('setPosition')
});
$('.modal__dialog').on("click", function(event) {
event.stopPropagation();
});
я догадываюсь что я должен написать
$(modalId).hide();
Но не понимаю как правильно это сделать