Skip to content

Instantly share code, notes, and snippets.

@Saabbir
Created August 4, 2019 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saabbir/3bff35196da5ae66158e54a504b2455e to your computer and use it in GitHub Desktop.
Save Saabbir/3bff35196da5ae66158e54a504b2455e to your computer and use it in GitHub Desktop.
A short function to get all siblings of an element.
/**
* Get siblings of an element
* @param {Element} elem
* @return {Array}
*/
function getSiblings(elem) {
return [...elem.parentNode.children].filter(item => item !== elem);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment