Created
April 13, 2012 23:17
-
-
Save avireni/2380741 to your computer and use it in GitHub Desktop.
set an event handler for any element that matches a selector
This file contains 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
$('button.someClass').live('click', someFunction); | |
//Note that in jQuery 1.4.2, the delegate and undelegate options have been | |
//introduced to replace live as they offer better support for context | |
//For example, in terms of a table where before you would use.. | |
// .live() | |
$("table").each(function(){ | |
$("td", this).live("hover", function(){ | |
$(this).toggleClass("hover"); | |
}); | |
}); | |
//Now use.. | |
$("table").delegate("td", "hover", function(){ | |
$(this).toggleClass("hover"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment