/ Published in: jQuery
Adding a namespace to an event can make it easier to unbind. It is very easy to unbind all events with the same namespace.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Bind Event One $("a").bind("click.nameOne", function(){ console.log("Event One Fire!"); return false; }); //Bind Event Two $("a").bind("click.nameTwo", function(){ console.log("Event Two Fire!"); return false; }); //Unbind all nameTwo events $("a.utwo").click(function(){ $("a").unbind(".nameTwo"); }); //Unbind all nameOne events $("a.uone").click(function(){ $("a").unbind(".nameOne"); });