insertAdjacentHtml method
- @DomName('Element.insertAdjacentHTML')
Parses text as an HTML fragment and inserts it into the DOM at the specified location.
The where
parameter indicates where to insert the HTML fragment:
-
'beforeBegin': Immediately before this element.
-
'afterBegin': As the first child of this element.
-
'beforeEnd': As the last child of this element.
-
'afterEnd': Immediately after this element.
var html = '
content'; // Inserts as the first child document.body.insertAdjacentHtml('afterBegin', html); var createdElement = document.body.children0
; print(createdElement.classes0
); // Prints 'something'
See also:
insertAdjacentText
insertAdjacentElement
Source
@DomName('Element.insertAdjacentHTML') void insertAdjacentHtml(String where, String text, {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { throw new UnsupportedError("Cannot invoke insertAdjacentHtml on SVG."); }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-svg/SvgElement/insertAdjacentHtml.html