mardi 4 février 2020

How to insert tag, or JS script through textContent?

I am looking for a way to insert JS script or Image tags with textContent.

There is a point on the site where I get a paragraph by

var game = document.getElementById("SomethingCool");

and to do

game.textContent = "<img src='https://i.imgur.com/GOO9vOH.png' alt='' height='42' width='42' id='ball'>"

but it will show the text and not an image because it's a string, so how can I insert the image? same for JS scripts.

thanks :D




Aucun commentaire:

Enregistrer un commentaire