jQuery - How to fade in/out from one color to another? (possible 3rd party plugin fo jQuery?)

南笙酒味 提交于 2019-12-05 01:52:34

jQuery UI extends jQuery's animate method to include colour animation. You can then do something like:

$("#someId").animate({backgroundColor: "#ff0000" });

Here's a working example.

You don't need another plugin. Example:

jQuery

$(selector).css("color", "blue");

CSS

selector {
  transition: color .3s;
}

This will work just fine (and without slowing down the website).

The jQuery UI animate function will do it.

See here for jsFiddle.

Here's my 2 cents worth - a jsFiddle of a continuously pulsating button, triggered when the document loads.

Demo here

function fadeDivIn(){
    $("#div").animate({backgroundColor: "#ed3" }, 4000, function(){fadeDivOut();});
}

function fadeDivOut(){
    $("#div").animate({backgroundColor: "#3de" }, 4000, function(){fadeDivIn();});
}

$(document).ready(function(){
    fadeDivIn();
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!