public
Created — forked from /jquery.deepest.js

jQuery 'deepest' plugin

  • Download Gist
jquery.deepest.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
$.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();
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.