[Home] >  DOM >  Insert given HTML before an element

Insert given HTML before an element

JavaScript version

const insertHtmlBefore = (html, ele) => ele.insertAdjacentHTML('beforebegin', html);

TypeScript version

const insertHtmlBefore = (html: string, ele: Element): void => ele.insertAdjacentHTML('beforebegin', html);