Skip to content

Instantly share code, notes, and snippets.

@beatrizsmerino
Last active October 22, 2019 16:26
Show Gist options
  • Save beatrizsmerino/905ad7674855c99c6a9930e6430f0e88 to your computer and use it in GitHub Desktop.
Save beatrizsmerino/905ad7674855c99c6a9930e6430f0e88 to your computer and use it in GitHub Desktop.
Pop up inside the html to position it above all
$(document).ready(function () {
// open popup
$(".popup__button-open").on("click", function () {
var $this = $(this),
$thisPopUp = $this.closest(".swiper-slide").find('.popup');
$thisPopUp.clone().appendTo(".global-locations").addClass("is-view");
// close popup
var timer = setInterval(function () {
if ($(".popup.is-view .popup__button-close").length > 0) {
clearInterval(timer);
$(".popup.is-view .popup__button-close, .popup.is-view").on("click", function (e) {
var $this = $(this),
$thisPopUp = $this.closest(".popup");
$thisPopUp.remove();
});
// close popup when click outside except when click inside of box
$('.popup.is-view .popup__inner').click(function (event) {
event.stopPropagation();
});
}
}, 100);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment