动画背景色jQuery [英] Animate Background Color JQuery

查看:77
本文介绍了动画背景色jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在互联网上搜索之后,似乎有多种方法可以通过jquery来设置颜色动画.

After searching the internet, it seems like there are a variety of approaches to animating color via jquery.

对我的包装器"的背景颜色从#FFF到#000进行动画设置的最佳方法是什么?

What is the best way for me to animate the background color of my "wrapper" from #FFF to #000?

 var open = true;
    $(".btn-slide").click(function(){ 
        if(open){
        $("#wrapper").animate({
            width: 900,  
            }, 
            1000, function() {
        });
    open= false;
    }else{
        $("#wrapper").animate({
            width: 250,  
            }, 
            1000, function() {
    open = true; }
});

感谢您的建议.我非常感谢您的投入.

Thanks for your suggestions. I am very grateful for the input.

推荐答案

您可以尝试

var open = true; 
        $(".btn-slide").click(function(){ 
        if(open){ 
        $("#wrapper").animate({ 
        width: 900, 
        backgroundColor: '#000' 
        }, 
        1000, function() { 
        }); 
        open= false; 
        }else{ 
        $("#wrapper").animate({ 
        width: 250,
        backgroundColor: '#000' 
        }, 
        1000, function() { 
        open = true; } 
        }); 

这篇关于动画背景色jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆