innerHTML doesn't work | Sololearn: Learn to code for FREE!

+2

innerHTML doesn't work

I tried to use the innerHTML on a paragraph and it didn' t work. please help me.

2/6/2021 12:28:47 PM

Gabriele Giambrone

15 Answers

New Answer

+5

Nazeekk I managed to make it work, thanks for the help. idk why it didn't work.

+9

Have a look at this example: https://code.sololearn.com/WXr5wf0KLFfe/?ref=app For using innerHTML and it works normally you have to use a script tag in html or onload the js in the js section (a window onload). Bcs if you don't use this method it comes error. It happened with me many times too, but I hope now you understand. For more add more details or the code. Happy coding :)

+6

GabrieleYT9768 How did you try?

+3

Tell more details🤔🤔

+3

GabrieleYT9768 Smth like "document.getElementById("test").innerHTML = "text" ??

+2

Nazeekk and I Am AJ ! I tryed with a function who had to change an empty paragraph but it didn't work

+2

I think.. that's have to work🤔🤔

+2

Nazeekk It's what i did and it didn' t work. i tried to use vars too, i tried to create one outside the function and inside but both didn't work. idk what to do, i need this function.

+2

before you post the exact code we cqnt hwlp you

+2

I think.. maybe thats just because you use SoloLearn editor. Try to use "Brackets" or "VisualCode"

+2

John Doe I'll make it

+2

Nazeekk I did it, it's from a lot of time that it doesn't work

0

Alyagout Babo What tf do you mean?

-1

<!DOCTYPE html> <html> <head> <title>Image selector viewer [demo for @Carl Moore]</title> </head> <body> <h1>Image selector viewer</h1> <h2>basic demo for @Carl Moore</h2> <p>Using &lt;iframe> for that purpose is too much heavy for nothing ^^ Just target an &lt;img> element instead, or even whatever element styled with a css background image...</p> <select onchange="setimg(this);"> <option></option> <option value="http://www.laboiteverte.fr/wp-content/uploads/2015/03/boucle-gif-geometrique-03.gif">image 1</option> <option value="http://www.laboiteverte.fr/wp-content/uploads/2015/03/boucle-gif-geometrique-02.gif">image 2</option> <option value="http://www.laboiteverte.fr/wp-content/uploads/2015/03/boucle-gif-geometrique-01.gif">image 3</option> </select> <img id="out"> </body> </html>