-2

I want the color of my div.navBtn elements to change through an animation effect. It isn't working out and I don't know why.

$(document).ready(function()
{
  $("button").click(function()
  {
    $("div.navBtn").animate(
    {
      width:'+=10px',
      backgroundColor: "#aa0000"
    });
  });
});

backgroundColor is what does the actual color changing but it does not work. Width +=10 works perfectly, backgroundColor does absolutely nothing. Is the syntax wrong or something??? I copied "backgroundColor: "#aa0000"" from another help posting here. Does anyone know what the problem is?

Mohammad Izady
  • 427
  • 3
  • 11
user2636774
  • 89
  • 1
  • 3
  • 11

2 Answers2

1

You have to include jQuery UI in order to animate colours with jQuery.animate.

Musa
  • 96,336
  • 17
  • 118
  • 137
1

You cannot animate colour's with jQuery You may have to use CSS instead or jQuery UI, but you shouldn't include that just to animate colours.

iConnor
  • 19,997
  • 14
  • 62
  • 97