Skip to content

Home

Array of element's siblings

Returns an array containing all the siblings of the given element.

const getSiblings = el =>
  [...el.parentNode.childNodes].filter(node => node !== el);

getSiblings(document.querySelector('head')); // ['body']

More like this

Start typing a keyphrase to see matching snippets.