Returns an array containing all the siblings of the given element.
Node.parentNode
and Node.childNodes
to get a NodeList
of all the elements contained in the element's parent....
) and Array.prototype.filter()
to convert to an array and remove the given element from it.const getSiblings = el =>
[...el.parentNode.childNodes].filter(node => node !== el);
getSiblings(document.querySelector('head')); // ['body']
JavaScript, Browser
Converts the given array elements into <li>
tags and appends them to the list of the given id.
JavaScript, Browser
Creates an element from a string (without appending it to the document). If the given string contains multiple elements, only the first one will be returned.
JavaScript, Browser
Renders the given DOM tree in the specified DOM element.