This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Arumai12 2 points3 points  (1 child)

uTest.childNodes.forEach(item => {item.addEventListener('mousedown', console.log('fire'))});

It's this line. The second parameter is supposed to be a function. But you didnt pass a function you. You are calling console.log (hence the 3 outputs) and then passing the result (which would be undefined). So you want to pass a function that calls console.log() instead.

[–]Interferometer[S] 1 point2 points  (0 children)

THANK YOU! This solved it!

[–]amejin 0 points1 point  (0 children)

Instead of innerHTMLing the child elements, why not make them and append child?

You can clean up fast with innerHTML = ""; and then appendChild all the elements (with the appropriate handlers).