-
-
Save Anima-t3d/1014671 to your computer and use it in GitHub Desktop.
jQuery 'deepest' plugin
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
$.fn.deepest = function() { | |
/* based on: http://stackoverflow.com/questions/3787924/select-deepest-child-in-jquery | |
* rewrite from: https://gist.github.com/714851 | |
* rewritten by: Anima-t3d march 1st 2011 | |
*/ | |
/// <summary> | |
/// Return the deepest child of this element. | |
/// var deepestElement = $("div").deepest(); | |
/// For example, when run on this structure: | |
/// | |
/// <div> | |
/// <span> <b>pick me!</b> </span> | |
/// <span> </span> | |
/// </div> | |
/// | |
/// It would return the element: | |
/// alert(deepestElement); | |
/// <b>pick me!</b> | |
/// </summary> | |
var $target = $(this).children(); | |
while( $target.length ) { | |
$target = $target.children(); | |
} | |
return $target.end(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This plugin seems to be more complex and has a little more functionality: https://github.com/martinille/jquery.deepest.js