I need to implement the functionality of jQuery\'s prevUntil() method in Vanilla JavaScript.
I\'ve got several elements on the same level:>
elements on the same level:>
How about this:
while ( node = node.previousElementSibling ) { if ( ( ' ' + node.className + ' ' ).indexOf( 'foo' ) !== -1 ) { // found; do your thing break; } }
Don't bother telling me that this doesn't work in IE8...