aderaaij
10/6/2017 - 3:06 PM

Get Siblings

Get siblings in vanilla js

export function getSiblings(elem) {
	var siblings = [];
	var sibling = elem.parentNode.firstChild;
	for ( ; sibling; sibling = sibling.nextSibling ) {
			if ( sibling.nodeType === 1 && sibling !== elem ) {
					siblings.push( sibling );
			}
	}
	return siblings;
}