Skip to content

Instantly share code, notes, and snippets.

@FreePhoenix888
Last active July 4, 2020 08:11
Show Gist options
  • Save FreePhoenix888/768864a2d90ffc346e37108c90555b16 to your computer and use it in GitHub Desktop.
Save FreePhoenix888/768864a2d90ffc346e37108c90555b16 to your computer and use it in GitHub Desktop.
ArrowForDropDownMenu
let body=document.querySelector('body');
if(isMobile.any()){
body.classList.add('touch');
let arrow=document.querySelectorAll('.arrow');
for(i=0; i<arrow.length; i++){
let thisLink=arrow[i].previousElementSibling;
let subMenu=arrow[i].nextElementSibling;
let thisArrow=arrow[i];
thisLink.classList.add('parent');
arrow[i].addEventListener('click', function(){
subMenu.classList.toggle('open');
thisArrow.classList.toggle('active');
});
}
}else{
body.classList.add('mouse');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment