I am having a bit of trouble with some javascript, I have searched for a question with an answer to this, but since it is probably one of the easiest things to do, I doubt anyone but myself could get it wrong.
I'm trying to simply make a content switcher, but the if statement that moved onto the next piece of content does not seem to be working:
//Work out next box
if (i == 2){var x=1;}else{var x=i+1;}
I've created a quick js fiddle (http://jsfiddle.net/TuMEa/5/) to try and get this working, I would be glad if someone could help me, thank you :)
(I have very little JS knowledge, but some programming knowledge (so I understand what things do))
xis only useful inside brackets{}?var x = i == 2 ? 1 : i + 1;? Also variable scope... Please see SO: JavaScript Variable Scopexshould be accessible from outside the brackets.