Is there a better way to achieve a toggle/switch then what I use. It works but it just seems clumsy to me.
var foo = true;
$(document).on("click","$element",function(){
if(foo){
//code
foo = false;
}
else{
//code
foo = true;
}
});
This is shorter and sweeter :
Unless the intermediate code is different in which case the solution depends on that code.