A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Element/insertAdjacentHTML below:

insertAdjacentHTML · WebPlatform Docs

insertAdjacentHTML Summary

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
Data-type
String

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. html
Data-type
String

Well-formed HTML code to insert. The string can be a combination of text and HTML tags.

Return Value

No return value

Examples

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

View live example

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.

Related specifications
DOM Parsing and Serialization
Living Standard
See also Related pages Attributions

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