Parses and inserts HTML code at or beyond the edges of an element within the document hierarchy.
Method of dom/Elementdom/Element
Syntax element.insertAdjacentHTML(where, html);
Parameters where
Where to insert the HTML text. Must be one of the following values:
Value Description “beforebegin” Before the element itself. “afterbegin” Just inside the element, before its first child. “beforeend” Just inside the element, after its last child. “afterend” After the element itself. htmlWell-formed HTML code to insert. The string can be a combination of text and HTML tags.
Return ValueNo return value
ExamplesThis example uses the insertAdjacentHTML method to insert script into the page.
var sHTML="<input type=button onclick=" +
"go2()" + " value='Click Me'><BR>"
var sScript='<SCRIPT DEFER>'
sScript = sScript +
'function go2(){ alert("Hello from inserted script.") }'
sScript = sScript + '</script' + '>';
ScriptDiv.insertAdjacentHTML("afterBegin",sHTML + sScript);
Usage
Use this method to add HTML to the page before/after an element or at the beginning or at the end of an element.
Notes
TODO: The notes below need to be verified.
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4