/ Published in: JavaScript
find the first ancestor on which comparisonFunc evaluates to true works the same way as a custom sort the el specified in the pram will be the FIRST el to which comparisonFunc is applied.
this is, this function considers me to be my own first ancestor :)
Expand |
Embed | Plain Text
/**************************************************************** ** Find Ancestor for which a function returns true ****************************************************************/ findAncestor: function ( el, comparisonFunc ) { if (comparisonFunc(el) == true) return el; else if (el.parentNode) { return arguments.callee(el.parentNode, comparisonFunc); } else return false; }
You need to login to post a comment.
