I want to create an array containing three different colours. Each time the user hits the Arrow Right key, I want the background-colour of div to change to the next colour, eventually getting back to the first colour in the array.


I managed to write some code but the colour will only change once.
How to fix this?
How many divs do you have in your html? If you only have one then this div:eq(‘+i+’) will not work. It is running through div:eq(0), div:eq(1) and div:eq(2).
Just do $(‘div’).css()….
Heads up though, it’s going to go VERY fast, you might not even see the colors cycle.
Oh I see. I think I have the wrong code then, cause what I want to achieve is going from one colour to the next each time the key is pressed
Members
Online

source