jquery - Unable to remove the class for the previous selected Item in Menu Bar -


When an item is selected under the menu bar, I am adding a class that activates the item.

It's working fine for the first time.

If we select a different element under the menu, how to remove the class first for the selected item?

This is my JSFilled

I tried to solve it

  $ (document)) .on (" Click "," # swiper-wrapper li ", function () {var previousselected = ''; if (Previously selected! = '') {$ ('#selected'). RemoveClass (active);} var Selectedleemnt = $ (This) .text (); $ (this) .addClass ("active"); previously selected) = selectedleemnt;});   

But I have not been able to remove the class for people with the prey.

Can someone help me?

What is #prevoiusselected? I've updated your:

  $ (document) .on ("click", "# swiper-wrapper li", function () {$ (". Active"). RemoveClass ("active"); $ (this) .addClass ("active");});    

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

Matlab transpose a table vector -

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -