Randomblue
Randomblue

Reputation: 116263

jQuery fadeTo() for colors

I want an equivalent of fadeTo() for colors, instead of opacity.

For example, starting with backgroundColor = "red", how can I gradually move to backgroundColor = "green" with jQuery?

Upvotes: 3

Views: 1117

Answers (2)

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76870

You could use animate()

 $('#yourdiv').animate({ backgroundColor: "green" }, 1000)

Upvotes: 4

knut
knut

Reputation: 4745

You need to use jQuery UI Color Animation.

You may also use CSS3 transitions which I prefer. Not supported in Internet Explorer 9 or older. Will be supported in Internet Explorer 10.

Upvotes: 4

Related Questions