我试图在 div
淡入时更改 background-color
但下面的代码不起作用。
相反,它只有 fadeOut
,当我尝试单击
fadeIn 时没有任何显示。
$('#divbutton').toggle(function(){
$('#divbutton').text('Show');
$('#message').fadeOut('1000');
} ,
function(){
$('#divbutton').text('Hide');
$('#message').$this.css('background-color', 'red').fadeIn('1000');
}
);
最佳答案
您对下一行的语法不正确。改变:
$('#message').$this.css('background-color', 'red').fadeIn('1000');
到:
$('#message').css('background-color', 'red').fadeIn('1000');
关于javascript - div淡入时改变背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15036924/