GitHub 6521★

Get all siblings of an element

JavaScript version

const siblings = (ele) => [].slice.call(ele.parentNode.children).filter((child) => child !== ele);

TypeScript version

const siblings = (ele: Node): Node[] => (ele.parentNode ? [].slice.call(ele.parentNode.children).filter((child) => child !== ele) : []);
Follow me on and to get more useful contents.