Created
August 4, 2019 05:22
-
-
Save Saabbir/3bff35196da5ae66158e54a504b2455e to your computer and use it in GitHub Desktop.
A short function to get all siblings of an element.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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