Difference between .click() vs .bind() vs .live()

Share the joy
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Difference between .click() and .bind()
.click() is itself a event which will perform some task in function

1
$("blah").click( function() { alert( "Click!" ); } );
$("blah").click( function() { alert( "Click!" ); } );

.bind() is use to bind multiple event with single id or tag

1
$("blah").bind( "click mouseover mousedown", function() { alert( "Click!" ); } );
$("blah").bind( "click mouseover mousedown", function() { alert( "Click!" ); } );

Difference between bind() and live()

bind()
.bind() attacheds events to elements that exist or match the selector at the time the call is made. Any elements created afterwards or that match going forward because the class was changed, will not fire the bound event.

live()
.live() works for existing and future matching elements. Before jQuery 1.4 this was limited to the following events: click, dblclick mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup


Share the joy
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.