jQuery UI主题很好--它们适用于整个文档,但是我有一些对话框的样式(如标题栏颜色)必须更改。
在我的jQuery UI css中,标题栏被编码:
..ui对话框..ui对话框-标题栏{填充:.4em 1em;位置:相对;}
这是我的javascript:
var $AlertDialog = $('<div"></div>')
.dialog({
autoOpen: false,
title: 'Alert Message',
buttons: {Ok: function() {$( this ).dialog( "close" );}}
});
function Alerter(cTxt)
{
$AlertDialog.html(cTxt);
$AlertDialog.css('ui-dialog-titlebar','color: red');
$AlertDialog.dialog('open');
};然后调用Alerter()作为警告()的替代。
访问和更改‘ui-对话框-标题栏’的颜色属性没有任何影响。
在这个问题之前,很多人都在阅读。似乎其他人也有类似的问题,但并不是jQuery UI特有的问题。
这是如何做到的呢?
更新:
多亏了一个很好的提示,我做到了这一点:
$AlertDialog.dialog('open');
$("#.ui-dialog .ui-dialog-title").css('color','red');
$("#.ui-dialog .ui-dialog-title").css('background-color','orange');很管用。但可以接受的做法?
发布于 2012-04-10 17:33:51
我的建议是不要使用..ui对话框选择器,因为一个页面上可能有多个对话框。您可以遍历标题栏。
...
$AlertDialog.html(cTxt);
// might as well use the theme since its part of jquery ui
$AlertDialog.prev().addClass("ui-state-error");
$AlertDialog.dialog('open');发布于 2011-10-15 20:21:54
首先,
根据文档,.css()将属性作为param。
似乎您正在尝试更改ui对话框标题栏。相反,试着这样做:
...
function Alerter(cTxt)
{
$AlertDialog.html(cTxt);
$AlertDialog.dialog('open');
$(".ui-dialog .ui-dialog-title").css('color','red');
$(".ui-dialog .ui-dialog-title").css('background-color','orange');
//Assuming you want to change header color only
//see the theming structure at http://jqueryui.com/demos/dialog/#theming
};https://stackoverflow.com/questions/7780207
复制相似问题