nearest foregoer node jquery


in javascript experience, i found unequivocally common assign "searching nearest foregoer an component condition (tag name, class,...)".
can parents() slight jquery job? method returned elements parents() predictable? top-to-bottom bottom-to-top?
for impulse i concentration function:



function ancestor(elem, selector) {
var $elem = $( elem ).parent();
while( $elem.size() > 0 ) {
if( $elem.is( selector ) )
relapse $elem;
else
$elem = $elem.parent();
}
relapse null;
}


can someone tell me there cunning proceed job?



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members