<template id="list-template">
<div class="list" id="list" style="margin: 1em;">
<div class="task" id="task">
<div class="task-txt">
<div class="task-header">Lorem</div>
<div class="task-description">Lorem ipsum dolor sit amet</div>
</div>
<div class="task-buttons">
<input type="button" class="task-done" value="done">
<button class="task-edit"><i class="fas fa-edit"></i></button>
<button class="task-delete" id="delete">Delete<i class="fas fa-trash"></i></button>
<input type="checkbox" class="task-follow">
</div>
</div>
</div>
</template>
<button id="add-button">Add</button>
<script>
var i = 1;
// пример добавления
document.getElementById("add-button").addEventListener("click", function(event) {
var list = document.getElementById("list-template").content.cloneNode(true);
list.querySelector(".task-header").textContent += "#" + i++;
document.body.appendChild(list);
});
// пример обработки события
document.addEventListener("click", function(event) {
if(event.target.matches(".list .task-delete")) {
event.target.closest(".list").remove();
}
});
</script>