Element.appendChild

Put a new child in the last position

struct Element
void
appendChild
(
E = Element
)
(
auto ref E el
)

Examples

Document doc = "<p>";
Element p = doc.byTagName("p").front;
p.prependSibling("<a>first-before</a><a><b>second</b></a>".asFragment);
p.appendSibling("<a>first-after</a><a><b>second</b></a>".asFragment);
assert(doc.toString() == `<html><head></head><body><a>first-before</a><a><b>second</b></a><p></p><a>first-after</a><a><b>second</b></a></body></html>`);
Document doc = `<p id="start">`;

Element p = doc.byTagName("p").front;
p.appendChild("<p>post</p><p>post1</p>".asFragment);
p.prependChild("<p>pre</p><p>pre1</p>".asFragment);
p.appendChild("<p>text</p>");

assert(doc.body.toString == `<body><p id="start"><p>pre</p><p>pre1</p><p>post</p><p>post1</p>&lt;p&gt;text&lt;/p&gt;</p></body>`);

Meta