How to animate background color in jQuery? -
what doing wrong following doesn't animate background color?
<div style="height:100px;width:100px;background:red">animate this</div><br> <input type="button" id="mybutton" value="start"/><br> $("#mybutton").click(function(){ $("div").animate({backgroundcolor: 'blue'}); });
you need import additional plugin such jquery ui in order support color in animate()
function jquery alone doesn't.
$("#colorbtn").click(function() { $('#demodiv').animate({backgroundcolor: 'blue'}) });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> <input type="button" id="colorbtn" value="change color"/><br> <div id="demodiv" style="height:100px;width:100px;background:red"></div>
Comments
Post a Comment