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
Post a Comment