Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
184
rated 0 times [  189] [ 5]  / answers: 1 / hits: 19323  / 12 Years ago, fri, november 16, 2012, 12:00:00

I've seen some very similar questions floating around but haven't been able to find the answer I'm looking for. I've already determined a work-around but would like to know the proper way to perform the task.



What I desire is to click the button and have the active state stay persistent. The next click will toggle the state and that is desired. What I really need to know is how to address the uiButton:active state.



HTML:



<input type='button' class='uiButton' id='testbutton' value='testValue'>


CSS:



.uiButton{
background-color: red;
}

.uiButton:active{
background-color:blue;
}


Javascript/jQuery:



$('.uiButton').click(function() {
$(this).toggleClass(//active state);
});

More From » jquery

 Answers
12

You should create an active class



CSS



.uiButton:active, .active {
background-color:blue;
}


JS



$('.uiButton').click(function() {
$(this).toggleClass(active);
});

[#81951] Thursday, November 15, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
declanm

Total Points: 614
Total Questions: 105
Total Answers: 97

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
;