Created
January 9, 2020 06:03
-
-
Save emmron/c04d097d7b4219f65c5b9d89ada747d3 to your computer and use it in GitHub Desktop.
mobile menu land surveyors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function() { | |
console.log("is ghis loading"); | |
$MenuItemOnClick = function() { | |
$( "li.menu-item-has-children" ).on( "click", function(e) { | |
e.preventDefault(); | |
let clickedItem = $(this).parent(); | |
console.log("I clicked on: ", clickedItem); | |
let SubMenu = $(clickedItem).find(".sub-menu"); | |
let allSubMenus = $('.sub-menu'); | |
let doesItHaveAClass = $(SubMenu).hasClass('showSubMenu'); | |
$(allSubMenus).removeClass('showSubMenu'); | |
console.log("Does it have a class", doesItHaveAClass); | |
if(doesItHaveAClass) { | |
$(SubMenu).removeClass('showSubMenu'); | |
console.log("Removing Class showSubMenu"); | |
} else { | |
$(SubMenu).addClass('showSubMenu'); | |
console.log("Adding Class showSubMenu"); | |
} | |
}); | |
}; | |
$MenuItemOnClick(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment