Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何通过菜单选择器更改背景颜色以匹配jQuery UI主题?_Css_Jquery Ui - Fatal编程技术网

Css 如何通过菜单选择器更改背景颜色以匹配jQuery UI主题?

Css 如何通过菜单选择器更改背景颜色以匹配jQuery UI主题?,css,jquery-ui,Css,Jquery Ui,当用户使用jQuery UI Themeselector更改页面主题时,我试图更改正文背景颜色 我试过这个 function updateBodyBackground() { $("body").css('background-color', $('.ui-widget-header:first").css("background-color") + ' !important;'); } 然后我在documentready上调用它(设置初始主题背景),并将其设置为主题选择器的onClo

当用户使用jQuery UI Themeselector更改页面主题时,我试图更改正文背景颜色

我试过这个

function updateBodyBackground() {
    $("body").css('background-color', $('.ui-widget-header:first").css("background-color") + ' !important;');
}
然后我在documentready上调用它(设置初始主题背景),并将其设置为主题选择器的onClose事件,如下所示

$function() {
    updateBodyBackground();
    $('#switcher').themeswitcher({ expires: 365, path: '/', loadTheme: "sunny", onClose: updateBodyBackground });
}
在Firefox中什么都不做,在Chrome中的变化似乎落后于一个,在IE8中选择器似乎根本不起作用

关于如何更改背景以更好地匹配所选jQueryUI主题,有什么建议吗


谢谢

使用超时修复错误

在meswitchertool.js中查找函数updateCSS()

之后 $(“标题”)。追加(cssLink)

如果仍然不起作用,请添加下面的增加超时

插入
setTimeout(“$('body').css('background-color',$('.ui小部件头:first').css('background-color'))”,2000)

使用超时修复错误

在meswitchertool.js中查找函数updateCSS()

之后 $(“标题”)。追加(cssLink)

如果仍然不起作用,请添加下面的增加超时

插入
setTimeout(“$('body').css('background-color',$('.ui小部件头:first').css('background-color'))”,2000)

您的js中有一个错误(使用了“代替”):

应该是:

$('.ui-widget-header:first')
但我发现这是可行的。不需要在meswitchertool.js中添加设置超时,将设置超时值降低到500,这样更改速度更快

function updateBodyBackground() {setTimeout("$('body').css('background-color', $('.ui-widget-header:first').css('background-color'))", 500);
}

$('#switcher').themeswitcher({ expires: 365, path: '/', loadTheme: "sunny", onClose: updateBodyBackground });

您的js中有一个错误(使用了“代替”):

应该是:

$('.ui-widget-header:first')
但我发现这是可行的。无需在meswitchertool.js中添加设置超时,将设置超时时间降至500,因此更改速度更快

function updateBodyBackground() {setTimeout("$('body').css('background-color', $('.ui-widget-header:first').css('background-color'))", 500);
}

$('#switcher').themeswitcher({ expires: 365, path: '/', loadTheme: "sunny", onClose: updateBodyBackground });

更好的方法是不使用计时器,只需使用一个jQueryUI CSS类和您要查找的背景颜色,在我的情况下,我喜欢以下人员选择的背景颜色:
ui状态悬停

<div id= "main_background" class= "ui-state-hover">
// Your Content
</div>

更好的方法是不使用计时器,只需使用一个jQueryUI CSS类和您要查找的背景颜色,在我的情况下,我喜欢以下人员选择的背景颜色:
ui状态悬停

<div id= "main_background" class= "ui-state-hover">
// Your Content
</div>