javascript - jQuery animate Background Color slideDown -


i trying animate background color when hovering element.

for instance, have div when hover, want background change red, , slidedown, , fadeout on mouse leave.

$('div.item').hover(function () {   $(this).css('background-color', 'red').slidedown(400); }, function () {     $(this).css('background-color', 'transparent').fadeout(400); }); 

there 2 issues this.. slidedown isnt working, color red comes in.. on mouse leave, element dissapearing (i assuming because fadeout working on element , not transition background-color).

is there tutorial or can achieve please?

you can achieve same effect making background image, using .animate change css , animation effects instead of keep chaining, code help:

$('#nav a') .css( {backgroundposition: "0 0"} ) .mouseover(function(){     $(this).stop().animate(         {backgroundposition:"(0 250px)"},          {duration:500})     }) .mouseout(function(){     $(this).stop().animate(         {backgroundposition:"(0 0)"},          {duration:500})     }) 

check link , see demo too!


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -