JavaScript for WordPress Forums Vanilla JavaScript What am I doing wrong here? Reply To: What am I doing wrong here?

#16024
Will
Participant

If the gallery-icon already contains the image, you’re wiping it out by setting innerHTML to something new. You should try creating a document fragment and appending all of your new HTML, and then using appendChild on the gallery-icon item