How to make background animation?

Jquery hover - How to make background color animation

  • <div class="post_each"> <h1 class="post_title">Apartamentos 1 comodo</h1> <img class="thumb" src="1.jpg"/> <img class="thumb" src="1.jpg"/> <img class="thumb" src="1.jpg"/> <img class="thumb last" src="1.jpg"/> </div> <div class="post_each"> <h1 class="post_title">Apartamentos 2 comodo</h1> <img class="thumb" src="1.jpg"/> <img class="thumb" src="1.jpg"/> <img class="thumb" src="1.jpg"/> <img class="thumb last" src="1.jpg"/> </div> <script type="text/javascript"> $('img.thumb').hover(function { $(this).animate({"background" : "white"}, 600); }); </script> hover() is not working at all. I just try to set either background color or border size should be increased when mouse hover.

  • Answer:

    You can’t animate colors (at least this way), only properties with one numeric value are allowed. There is a separate color animation plugin you need to add. That anonymous function is missing parentheses: $('img.thumb').hover(function () {

user1124927 at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

You don't need jquery.... .thumb { background: #000; transition: 0.5s; -moz-transition: 0.5s; -webkit-transition: 0.5s; -o-transition: 0.5s;} .thumb:hover { background: #fff; transition: 0.5s; -moz-transition: 0.5s; -webkit-transition: 0.5s; -o-transition: 0.5s;} http://jsfiddle.net/NotInUse/fvac8/

Scott

you can use color plugin.. http://stackoverflow.com/questions/190560/jquery-animate-backgroundcolor $('img.thumb').hover(function(){ $(this).animate({ backgroundColor: 'white' }, 600); }); you can also refer previous threads http://stackoverflow.com/questions/425082/jquery-backgroundcolor-animation and http://stackoverflow.com/questions/190560/jquery-animate-backgroundcolor

dku.rajkumar

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.