Return to Snippet

Revision: 12362
at March 12, 2009 06:18 by 1man


Initial Code
//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");
});

Initial URL

                                

Initial Description
Adding a namespace to an event can make it easier to unbind. It is very easy to unbind all events with the same namespace.

Initial Title
jQuery event namespace

Initial Tags
event, jquery

Initial Language
jQuery