What is .divClick here ??
$("div#div1").bind("click.divClick",function(){alert("Div Clicked");})
some one ask me this question and i have no answer for that. is it event type or namespace ?
Events in jQuery can be written like this:
<event-type>[.<event-namespace>]
In your case, click.divClick
is just a click
event, except that it's organized in the divClick
namespace.
One advantage of using namespaces is when you need to unbind event listeners:
$(el).bind('click', function() { alert('click 1'); };
$(el).bind('click.divClick', function() { alert('click 2'); };
$(el).unbind('click.divClick');
The last line will unregister only the click 2
event handler without affecting the click 1
event handler.
You can also unregister all events from a namespace:
$(el).unbind('.divClick');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With