Is there a way to change the colour of a div as it moves across the screen in the horizontal plane?
I would need it to change 5 times to different colours and not animate across the spectrum, just suddenly change.
Any Help Appreciated.
The first is do something like: document.getElementById(‘yourID’).style = ‘color:#XXXXXX’;
or, you could use JQuery if you want a little more functionality. I’d recommend using JQuery only if you plan to use it a bunch, otherwise, it’s extra bandwidth for a simple color change.
Build a function like this:
then simply call the function with the color and id on any event you choose.
the code that Democritus supplied will change the color, as far as when it changes color, you still have to specify that.
Without knowing more, like how the div moves, and when it should change color, we can’t really offer any more help.
You must be logged in to reply to this topic.