element.insertAdjacentHTML()
element.insertAdjacentHTML() is a JavaScript method in the DOM category. Parses HTML and inserts it at a position. The syntax is element.insertAdjacentHTML(position, text). A typical example: element.insertAdjacentHTML("beforeend", "
Hi
"). A close sibling is
document.getElementById(), which returns the element with the specified ID. A close sibling is
document.querySelector(), which returns the first matching element. A close sibling is
document.querySelectorAll(), which returns all matching elements as a NodeList. A close sibling is
element.addEventListener(), which attaches an event handler. More about this category: DOM methods for interacting with HTML elements. Related DOM methods:
document.getElementById(),
document.querySelector(),
document.querySelectorAll(),
element.addEventListener(),
element.removeEventListener(),
document.createElement(),
element.appendChild(),
element.removeChild(). This page is part of the free JS Reference documentation covering 1027+ methods, each with syntax, parameters, return values, examples, and common pitfalls. You can try element.insertAdjacentHTML() immediately in the
JavaScript playground, look up unfamiliar terms in the
glossary, or return to the
JS Reference homepage.