The best jQuery UI Examples - Color Animation (Color Animation) Tutorial In 2024, In this tutorial you can learn Anime (Animation) Demo,
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 = "http://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>