Reputation: 120799
I would like to add some text to an element in the DOM. How do I do this in Dart?
Upvotes: 2
Views: 1208
Reputation: 76353
You can use Element.text to set the text content of the element or Element.appendText to add a text after the last child of the element :
import 'dart:html';
main() {
var elem = new DivElement();
// replace content with the text
elem.text = "the text";
// add a text after the last child of this element
elem.appendText("the text");
}
Upvotes: 1
Reputation: 33
New syntax of previous answer:
import 'dart:html';
main() {
var elem = new DivElement();
elem.appendText("the text");
}
There is new import style and method appendText(String text)
for adding the specified text after the last child.
Upvotes: 0