Click here to Skip to main content
15,886,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have the page that hase six buttons, this buttons work as menu, now when 1 button is clicked after that i want to change the color of this button and this color will not change only for button pressed and release. If button was selected then its color will be change and when press next button the original color will be recover of 1st button and next will be changed.

What I have tried:

.btn:active{

}
.btn:hover{
}
Posted
Updated 26-Feb-16 1:57am
Comments
Sinisa Hajnal 26-Feb-16 7:55am    
It doesn't work that way. You have to add some css class to the button that will change its color. Hover and Active pseudo-classes in CSS will work just as long as the item is hovered / clicked.

1 solution

Create javascript function that will be called on button click.

1. Get your menu buttons
2. Iterate through the collection
3. remove "active" from all buttons in the menu.
3.a. Add "active" class to clicked button

Bind the function to all menu button click events.
 
Share this answer
 
Comments
Member 11693314 27-Feb-16 5:26am    
Thank you so much,
but i want some snippet of it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900