JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>Li</li>
<li>Li</li>
<li>Li</li>
</ul>
JavaScript
//that isn't work
const bind = (elem = document) => {
for (const li of elem.querySelectorAll("li")) {
li.onmousedown = () => console.log("click");
}
};
bind();
setInterval(function() {
//update
const ul = document.querySelector("ul")
const copy = ul.cloneNode(true);
bind(copy);
ul.parentNode.replaceChild(copy, ul);
}, 500);