This example demonstrates adding and removing elements dynamically. Inserted elements can contain their own event handlers recursively. Clicking the "+" button appends a new input row with its own "–" button that removes the row when clicked.
<div>
<input type="text" name="items[]">
<button style="width: 32px">+</button>
<on click>
<!-- Add row to preview -->
<selection-change parent=".preview">
<selection-append-children>
<div>
<input type="text" name="items[]">
<button style="width: 32px">-</button>
<on click>
<!-- Delete row -->
<selection-change parent>
<selection-delete>
</on>
</div>
</selection-append-children>
</on>
</div>
.preview.