HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Use .animate () to achieve color animation.
For more information about color animation (Color Animation) details, see the API documentation Color Animation (Color Animation) .
jQuery UI bundled jQuery Color plugin, jQuery Color plugin provides color animation and many other color-related utility functions.
Click the button to preview effects.
<! Doctype html> <Html lang = "en"> <Head> <Meta charset = "utf-8"> <Title> jQuery UI Effects - Animation (Animation) Demo </ title> <Link rel = "stylesheet" href = "// code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <Script src = "// code.jquery.com/jquery-1.9.1.js"> </ script> <Script src = "// code.jquery.com/ui/1.10.4/jquery-ui.js"> </ script> <Link rel = "stylesheet" href = "https://jqueryui.com/resources/demos/style.css"> <Style> .toggler {width: 500px; height: 200px; position: relative;} #button {padding: .5em 1em; text-decoration: none;} #effect {width: 240px; height: 135px; padding: 0.4em; position: relative; background: #fff;} #effect h3 {margin: 0; padding: 0.4em; text-align: center;} </ Style> <Script> $ (Function () { var state = true; $ ( "#button") .click (Function () { if (state) { $ ( "#effect") .animate ({ backgroundColor: "# aa0000", color: "#fff", width: 500 }, 1000); } Else { $ ( "#effect") .animate ({ backgroundColor: "#fff", color: "# 000", width: 240 }, 1000); } state = state!; }); }); </ Script> </ Head> <Body> <Div class = "toggler"> <Div id = "effect" class = "ui-widget-content ui-corner-all"> <H3 class = "ui-widget-header ui-corner-all"> Anime (Animation) </ h3> <P> Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi. </ P> </ Div> </ Div> <a href="#" id="button" class="ui-state-default ui-corner-all"> switching effects </a> </ Body> </ Html>