Insert given html after or before an element

Insert after

Insert html after the ele element:

ele.insertAdjacentHTML('afterend', html);

Insert before

Insert html before the ele element:

ele.insertAdjacentHTML('beforebegin', html);

More

Previous
Insert an element after or before other element
Next
Load a css file dynamically