Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add arbitrary HTML to an element in Dart?

Tags:

dart

I would like to add arbitrary bits of HTML (like <span>hello</span>) to an element. How do I do this in Dart?

like image 947
Seth Ladd Avatar asked Aug 29 '12 12:08

Seth Ladd


1 Answers

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.

like image 182
Seth Ladd Avatar answered Oct 25 '22 18:10

Seth Ladd