fix close lang menu click outside
This commit is contained in:
parent
9989413cd5
commit
d4b709dfc5
2 changed files with 19 additions and 8 deletions
|
|
@ -1,12 +1,19 @@
|
|||
document.getElementsByClassName("header-lang-small")[0].addEventListener("click", function(){
|
||||
document.addEventListener("click", function(){
|
||||
var langSelector = document.getElementsByClassName("header-lang-small")[0];
|
||||
var dropdown = document.getElementById("dropdown");
|
||||
var dropdownIcon = document.querySelector('.header-lang-small .icon');
|
||||
console.log(dropdownIcon);
|
||||
if (dropdown.style.display === "block") {
|
||||
dropdown.style.display = "none";
|
||||
dropdownIcon.classList.toggle('active');
|
||||
var isClickInside = langSelector.contains(event.target);
|
||||
if (isClickInside) {
|
||||
if (dropdown.style.display === "block") {
|
||||
dropdown.style.display = "none";
|
||||
dropdownIcon.classList.toggle('active');
|
||||
} else {
|
||||
dropdown.style.display = "block";
|
||||
dropdownIcon.classList.toggle('active');
|
||||
}
|
||||
} else {
|
||||
dropdown.style.display = "block";
|
||||
dropdownIcon.classList.toggle('active');
|
||||
}
|
||||
dropdown.style.display = "none";
|
||||
dropdownIcon.classList.remove('active');
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue