Question:
Lets suppose I have a rectangular div called sun.I have 4 colors for the div.
The colors are red, green, blue and yellow respectively.
The initial color is red.
What I want is when user clicks on the rectangle, the color of rectangle should change from red to green. When clicked again, green to blue, and thus on another click, blue to yellow and atlast when user clicks again the color should change from yellow to red and the cycle should continue. I can not implement such algorithm.
Answer is appreciated if if-else tree is used (although not necessary).
Answer:
Like @Bravo comment you can use javascript array and add with eventListenerIt rought but that it.
If you have better answer, please add a comment about this, thank you!