If you want to toggle the class when clicked why have you also removed that same class when the mouse leaves? That means as soon as you move the cursor the class you just applied on click will be removed.
Off topic: You shouldn’t really be using the anchor element without an href (unless you know why) as that has accessibility issues and tab issues. It probably should be a button element anyway.