I’m sure it’s a simple problem, and has an obvious answer, but the fact of the matter is I can’t work it out. Basically, if the div is clicked, and the variable exists, do this, if not, do that. But none of it works.
Ideas?
$("#lisea").click(
var set = false;
if(set) {
function() {
$("body").animate({
opacity: 1
}, 500);
var set = false;
}
}
if(!set) {
function() {
$("body").animate({
opacity: 0.25
}, 500);
var set = true;
}
}
);
You need your code inside a callback function – not just as a parameter. You’re also just defining a function in your condition – you need to invoke it.
Anyway I think this is probably what you want:
Here’s a demo: http://jsfiddle.net/upqTZ/