MandoMando
MandoMando

Reputation: 5515

How do you override CSS applied by jQuery UI theme properly?

According to this question (and common sense) I should be able to change characteristics of a jQueryUI Widget such as a button after load. For example, set the background of a particular Button Red.

When I try using css or even using the $('.selector').css({'background-color': 'Red'}) after the .button() call, the button flashes red on load and goes back to the jQuery UI theme. How do I stop jQuery UI from overriding the overrides?

Upvotes: 1

Views: 1279

Answers (2)

Jonathan Rowny
Jonathan Rowny

Reputation: 7588

jQuery UI supplies a neat callback for when it's done creating the element. That's where you'd want to do the color change.

$( ".selector" ).button({
    create: function(event, ui) {
    $('.selector').css({'background-color': 'Red'})
}
});

Upvotes: 3

Calvin
Calvin

Reputation: 8775

Are you selecting for the button element or its child span tag? This example works for me:

http://jsfiddle.net/8UvZ5/

Upvotes: 2

Related Questions