As of jQuery 1.8, the .toggle() utility function is deprecated, and I'm looking across Stack Overflow to no avail for a quickie snippet to mimic its functionality. I looked at a proposed solution here but I find it too verbose.
I wonder if I should toggle a custom class name and do an .on() / .off(), or if I should track a boolean value?
In my mind I'm thinking I should be able to do it all in a single .on() event map...
Has anyone here done it before and can share a snippet?
What I came up with is this: anyone have ideas how to avoid using a global variable to track my click state?
g.toggler = 0;
$(document).on({
click : function(){
g.toggler++;
if(g.toggler%2==1){
console.log('forth');
} else {
console.log('back');
};
}
});