javascript - How to remove active class by mouse click -


I have created two boxes that will change the background to the hover and the active position. Here's my job:

There, when I click on "One", it will be set to the active state (Green Background). no problem. When I click on "Two", it will be set to active status and "A" will return to its previous state (gray background). It is also good for me

But, I want that when "one" is set on an active state, at that time, if I click on "One", then that general position (gray background) ) But the same event should also be for "two". How can I make it?

My applicable script:

  $ ('toggle'). Click (function () ($. 'Toggle'). RemoveClass ("active"); $ (this) .toggleClass ("active");});   

........... UPDATE ...........

Krishna Help me with this: Click

  $ ('toggle') (function () {$ ('toggle'). (Not this) .removeClass ("active") ; $ (This) .toggleClass ("active");});   

I have seen an issue that should be updated for my project The issue is: If "a" is on "active" status, at that time, if a user is "one ", It will return back to its original state. But, if the user does not remove his mouse pointer from that button, then that button also looked at the green background. This is for hover color. Therefore, if a user repeatedly clicks a button, he will not be able to understand whether the state has changed or not, until he / she's pointer is transferred. < P> Therefore, I need (when the mouse pointer is not mounting by the user): If a person clicks the "One" button, then it turns into a "green background". If the user clicks on "One" again, he will change to "gray background" (to understand that the change is not to move the user to his mouse pointer). At least the hover should be disabled in color, if the user clicks the mouse pointer again without the button

No (this)

  Use $ ('toggle'). Click (function () ($ ('. Toggle'). No (this) .removeClass ("active"); $ (this) .toggleClass ("active");});   

EDIT:

ME @ ROCO C The touch of Bulzon liked in CSS, to separate the hover vs. click (in comments)

 . Toggle: Hover {background: # 888; } .toggle.active {background: green; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -