Created
July 1, 2011 13:58
-
-
Save craigmdennis/1058591 to your computer and use it in GitHub Desktop.
Descendent of - jQuery Plugin
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
(function($) { | |
$.fn.descendantOf = function(parentId) { | |
return this.closest(parentId).length != 0; | |
} | |
})(jQuery) | |
/* | |
* USAGE | |
* $('#element').descendantOf('#another-element'); if #element is within #another-element then this will return true | |
* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment