Monday, February 28, 2011

Bind vs Click Events in Jquery

Bind vs Click Events in Jquery.


Both perform the same function


var message = 'Spoon!';
$('#foo').bind('click', function() {
  alert(message);
});
$('#foo').click(
  alert(message);
);
are same the only difference is you can unbind the event programmatically example
If someone wants to perform the event once and then not perform the event after
that on an element you will have to use bind instead of click and then unbind it 
later 
in the code.