How is possible in a nav

To select when clicked in first time then add class to an element and when click on second that time remove class for addes element before?

I try to search but… I know what I want but I not really found a solution for select second click in same nav element any idea?

Thanks

as far as I understand, You can create JavaScript function to handle this

Yes but I mean when click on nav second time then remove prev addClass one with a removeClass…

  • using jQuery, you can use toggleClass() function.
  • using JS you can use Element.classList that returns you a list of the classes.
  • Or you can create a counter as a global variable … once this function is called first time, it assign for example 1 to this counter and when it’s called second time it re-assign the counter to 0… and 1 mean the class is added and 0 means the class is removed … you can check the value of it when you call the function.