I would like to add arbitrary bits of HTML (like <span>hello</span>
) to an element. How do I do this in Dart?
You can add arbitrary bits of HTML to an element with appendHtml('<span>some html</span>')
, like this:
import 'dart:html';
main() {
var elem = new DivElement();
elem.appendHtml('<span>hello</span>');
}
The appendHtml
method will parse the HTML and add the resulting node as the last child of the element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With