I have a very simple function which should change the page background colour based on specific links being clicked, but I can’t figure out why it’s not working.
Here is a demo of what I have so far: http://jsfiddle.net/cF74Y/
It seems like it must be such a trivial mistake, but I can’t see it. Any help would be greatly appreciated.
You are compare string with number, change
switch (currentItem)toswitch (+currentItem)will make your demo work.Addition: You could pass the
currentItemas a parameter instead of using global variable.Here is the working demo.