document.querySelector("#wrapper").addEventListener("click", function(event) { if (event.target.matches(".task")) { console.log("dynamic task was clicked"); } });