Skip to content

Instantly share code, notes, and snippets.

@emmron
Created January 9, 2020 06:03
Show Gist options
  • Save emmron/c04d097d7b4219f65c5b9d89ada747d3 to your computer and use it in GitHub Desktop.
Save emmron/c04d097d7b4219f65c5b9d89ada747d3 to your computer and use it in GitHub Desktop.
mobile menu land surveyors
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