Toggle class on menu but also remove class
hi guys - i need some help with something relatively simple.
i have a bunch of menu items
- item 1
- item 2
- item 3
- item 4
when i click any of the items i need to toggle a class 'open' indivually for each item but if i click on another item example item 3 i need to remove the class open.
this is how my code looks so far - i am able to toggle the class but it doesn't get removed when click on the different items.
- $('#Menu1 .DropDownInner').on('click', function(e){
- e.preventDefault();
-
- $('li.dropdown').not(
- $(this).parent().toggleClass('open').parent().removeClass('open')
- );
- });
any help would be appreciated.
many thanks