Tuesday, April 2, 2013

Jquery: Change div background color using animate

You cannot use animate to animate colors without jQuery UI. So use

...

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
...
...
...

$( "#effect" ).animate({
          backgroundColor: "#fff",
          width: 240
        }, 1000 );


...
...
Resource:
http://stackoverflow.com/questions/6492418/changing-background-of-a-div-using-jquery
http://jqueryui.com/animate/

No comments: