execute only if element is on page
This commit is contained in:
parent
eb36eb4ba3
commit
8e1d48dc66
2 changed files with 22 additions and 14 deletions
|
@ -1,5 +1,9 @@
|
|||
document.querySelector("#burgerMenu").onclick = () => {
|
||||
document.getElementById("burgerMenu").classList.toggle("change");
|
||||
document.getElementById("mainMenuContainer").classList.toggle("visible");
|
||||
let burgerMenu = document.querySelector("#burgerMenu");
|
||||
|
||||
if(burgerMenu != null) {
|
||||
burgerMenu.onclick = () => {
|
||||
document.getElementById("burgerMenu").classList.toggle("change");
|
||||
document.getElementById("mainMenuContainer").classList.toggle("visible");
|
||||
|
||||
}
|
||||
}
|
26
js/cookie.js
26
js/cookie.js
|
@ -10,15 +10,19 @@ function getCookie(name){
|
|||
return null
|
||||
}
|
||||
|
||||
let cookieInfo = document.querySelector(".cookieinfo");
|
||||
if (getCookie("cookieMessageHide") === "1"){
|
||||
cookieInfo.style.display = "none";
|
||||
} else {
|
||||
cookieInfo.style.display = "block";
|
||||
}
|
||||
|
||||
document.querySelector(".cookieinfo-close").onclick = function() {
|
||||
console.log("close");
|
||||
document.cookie = "cookieMessageHide=1";
|
||||
cookieInfo.style.display = "none";
|
||||
}
|
||||
let cookieInfo = document.querySelector(".cookieinfo");
|
||||
if(cookieInfo != null) {
|
||||
if (getCookie("cookieMessageHide") === "1") {
|
||||
cookieInfo.style.display = "none";
|
||||
} else {
|
||||
cookieInfo.style.display = "block";
|
||||
}
|
||||
|
||||
document.querySelector(".cookieinfo-close").onclick = function() {
|
||||
console.log("close");
|
||||
document.cookie = "cookieMessageHide=1";
|
||||
cookieInfo.style.display = "none";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue