- Add as the last child node of the parent element
element.appendChild(childNode)
https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
- Add as the first child node of the parent element
element.prepend(childNode)
https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend
- Insert at the specified position
element.insertAdjacentHTML(position, text);
- Position:
'beforebegin': Before theelementitself.'afterbegin': Just inside theelement, before its first child.'beforeend': Just inside theelement, after its last child.'afterend': After theelementitself.
<!--beforebegin--><p><!--afterbegin--> foo <!--beforeend--></p><!--afterend-->
https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML