Skip to content

Instantly share code, notes, and snippets.

@neerajsingh0101
Created March 5, 2010 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save neerajsingh0101/322813 to your computer and use it in GitHub Desktop.
Save neerajsingh0101/322813 to your computer and use it in GitHub Desktop.
//this one works
$('#container a').filter('.top').bind('click', function(e){
log( $(this).text() + ' clicked1');
return false;
});
//this one does not work
$('#container a').filter('.top').live('click', function(e){
log( $(this).text() + ' clicked1');
return false;
});
//this one does not work. this would have been awesome. it is a direct replacement of bind
$('#container a').filter('.top').delegate('click', function(e){
log( $(this).text() + ' clicked1');
return false;
});
//even this one does not work
$('#container a').delegate('.top', 'click', function(e){
log( $(this).text() + ' clicked1');
return false;
});
//this one works but see how far it is from the original bind statement.
//this break chainability
// UPDATE: this example(4th one) was mistakenly posted as exactly same as 3rd example. I am correcting it.
$('#container').delegate('a.top', 'click', function(e){
log( $(this).text() + ' clicked1');
return false;
});
//tested with jQuery 1.4.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment