SpaceNinja
SpaceNinja

Reputation: 512

Having trouble cycling through background colors in JavaScript

I would like to animate the background color the way the text does in this script. It does a fine job of slowly cycling through colors, but the script only applies this effect to a Span tag, and I'd like it to apply to the Body tag. I tried applying "sp1" to the Body, and even trying to put the whole page into a big Div and apply it there, but it doesn't work. Anyone have any ideas?

I'm not going to clog up this post with all the code because it's just a view-source of this page:

http://www.javascript-fx.com/development/colorcycle/spancycle.html

Thank you very much, anyone who can lend some direction!

Upvotes: 1

Views: 115

Answers (1)

Dan
Dan

Reputation: 364

Your post kind of cuts out:

is effect to a , and I'd like it to apply to the .

I assume you want to do the background rather than the text color, correct? If so change the line:

faderObj[i].style.color = getColor(start, end, index);

to:

faderObj[i].style.backgroundColor = getColor(start, end, index);

Otherwise, please clarify.

Upvotes: 1

Related Questions