0
下面的演示页面代码。我做了一个聪明的通知。我可以看到,在CSS中,它被设置为背景黑色,我尝试在创建时动态地将其更改为不同的颜色,当我在检查器中执行此操作时工作,但不在代码中。任何帮助表示赞赏(我基本上试图使它的黑色初始通知随机颜色)。动态更改通知背景
// With Input
$('.MessageBoxContainer').css({backgroundColor: 'red'});
// This is what I try to change colour, des not work
$.SmartMessageBox({
title : "Welcome to the Clevertree demonstration.",
content : "Please enter your name to continue",
buttons : "[Accept]",
input : "text"
},
function(ButtonPress, name) {
//alert(Value);
$(".chosen_name").html(name);
$.ajax({
'url' : 'http://clevertree.co.uk/index.php/site/blankadd',
'type' : 'POST', //the way you want to send data to your URL
'data': {
name: name
},
'async': false,
'success' : function(data){ //probably this request will return anything, it'll be put in var "data"
if(data){
userInfo = jQuery.parseJSON(data);
//userInfo.User_ID
//alert(userInfo.User_ID);
$('.MessageBoxContainer').css({backgroundColor: 'red'});
// I try again here, still does not work
}
}
});
感谢。这是所有的代码真的要生成对话框。我不会在HTML中调用任何东西。上面的代码在页面加载时自动调用。我可以在javascript中改变它的颜色,而不用编辑CSS(因为我还想要一些黑色的)? – user1149620