user1330974
user1330974

Reputation: 2616

jQuery UI button change color in focus

I'm trying to customize the color of the button in jQuery UI by adding custom CSS to the <label> as seen here: http://jsfiddle.net/Akedf/3/

I would like to change the color of those buttons when they have been clicked on (preferably just using CSS). I've been looking a lot of StackOverflow (example one) and Google posts about changing color of the jQuery UI buttons, but none of them seem to work. Maybe because I just started learning about jQuery, CSS and HTML stuff. If anyone can show me how to do achieve that, I'd greatly appreciate the help. Thank you

Edit: by focus I meant the appearance after someone clicked on the button.

Upvotes: 0

Views: 982

Answers (1)

KJ Price
KJ Price

Reputation: 5984

I don't think regular html elements have a focus attribute. You could use a checkbox or radio button, but as for a <label/>, you would probably have to just use javascript. If you are using jQuery, then it is really simple:

$("label").click(function(){
    $(this).addClass('focus');
});

As far as the css:

label.focus, input[type=radio]:focus{
    background: #0c0;
}

Upvotes: 1

Related Questions