I’m trying to teach myself some basic jquery and am having trouble with an if statement I’m trying to use. My code is as follows:
var animate = 0;
$('a').click(function () {
if (animate == 0) {
$('#shadow').fadeOut(500);
var animate = 1;
}
});
I’m hoping to use some else statements further down the line, so that depending on the value of “animate” it will perform a different jquery action when clicked. I’m sure I’ve overlooked something obvious, but I’m banging my head against a wall trying to figure out what it is.
Any help would be most appreciated!
You shouldn’t use the
varkeyword again when assigning 1 toanimate. By doing this, you are causing a syntax error sinceanimatehas already been declared within the same scope.