Skip to content
Advertisement

Inserting text content using same class multiple times

I’m currently trying to insert text content that change depending of image validation using a single class for multiple divs. Any help is appreciate!

HTML

JavaScript

Right now using the next Javascript it’s inserting the text content but it only does it once per “.spanner” class, not in the rest.

JavaScript

JavaScript

I’m trying to figure out how to make it work using something like this:

JavaScript

JavaScript

Thanks in advance!

Advertisement

Answer

First off, there is a problem, multiple HTML elements cannot share the same id attribute, you must switch them for classes, also “//user/trophies/A.png” is probably not a valid directory

HTML:

JavaScript

Now, JavaScript can handle your HTML much better

Javascript:

JavaScript

If you need more help, just reply to this answer 🙂

Advertisement