Reputation: 1125
I have something like this:
$div = $('<div id="error" title="Error">');
$div.append('<p>Hi</p>');
$div.dialog({
modal: true,
maxHeight:500,
});
Can i change background color of dialog title somehow like this?:
$div.dialog({
modal: true,
maxHeight:500,
}).find(".ui-dialog-titlebar").css("background-color","red");
Upvotes: 20
Views: 48370
Reputation: 1552
Most simple way is this: -
.ui-dialog-titlebar {
background:red;
}
Upvotes: 2
Reputation: 2136
Another method to do is to :
Define your styling class - myTitleClass
Define the css as
. myTitleClass .ui-dialog-titlebar {
background:red;
}
and add the custom class to the dialog initialization function :
$( "#dialog" ).dialog({
autoOpen: false,
dialogClass: 'myTitleClass'
});
JSFiddle - (but with another sample code)
Upvotes: 24
Reputation: 38262
Use prev()
instead of find()
because that element is not inside $div
:
$div.dialog({
modal: true,
maxHeight:500,
}).prev(".ui-dialog-titlebar").css("background","red");
Also I use background
to override all other elements like background-image
Check this http://jsfiddle.net/Ad7nF/
Upvotes: 30