gpt4 book ai didi

jquery - 动态更改通知背景

转载 作者:行者123 更新时间:2023-11-28 10:08:24 25 4
gpt4 key购买 nike

下面的演示页面代码。我做了一个智能通知。我可以看到在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com