/html-dom /Basic
GitHub 4932★

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);

See also

Follow me on and to get more useful contents.