下面的演示页面代码。我做了一个智能通知。我可以看到在 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
}
}
});
最佳答案
你可以像下面这样写来改变css颜色
$('.MessageBoxContainer').css('background-color','yellow');
在这里查看 jsfiddle: http://jsfiddle.net/24XE2/3/
你能把你的html也贴上来吗
关于jquery - 动态更改通知背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24467617/