Created
March 5, 2010 15:29
-
-
Save neerajsingh0101/322813 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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