Skip to content

Instantly share code, notes, and snippets.

@Newol1
Last active March 12, 2020 15:58
Show Gist options
  • Save Newol1/2f974101066b52800de7b5581712197d to your computer and use it in GitHub Desktop.
Save Newol1/2f974101066b52800de7b5581712197d to your computer and use it in GitHub Desktop.
JavaScript Self Libraries
function popUp(popUp_content, popUp_container) {
let elem = $(popUp_content);
let container = $(popUp_container)
if (!container.hasClass("show__pop-up-container")) {
container.addClass("show__pop-up-container");
}
$(document).on("mouseup", function em(e) {
if (!elem.is(e.target) && elem.has(e.target).length === 0 && container.hasClass("show__pop-up-container")) {
$(document).off("mouseup", em, true);
container.removeClass("show__pop-up-container");
}
})
}
var pathname = window.location.pathname; // Returns path only (/path/example.html)
var url = window.location.href; // Returns full URL (https://example.com/path/example.html)
var origin = window.location.origin; // Returns base URL (https://example.com)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment