Display a variable value as a <p> element? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Display a variable value as a <p> element?

How can I display a variable value as a <p> element? All I need is the Javascript code. I’ve tried: var score = 0; document.getElementById(“test”).innerHTML = score; var score = 0; document.getElementById(“test”).value = score; ——— This is what the <p> tag inside of the <body> tags looks like: <p id=“test”></p>

26th Jul 2021, 8:43 PM
<p id=“username”>The Cuber</p>
<p id=“username”>The Cuber</p> - avatar
3 Answers
+ 2
It seems to be your parenthese. Use the up and down ones found when coding. Use these "" not these “” https://code.sololearn.com/WICUzTAzoFb4/?ref=app
26th Jul 2021, 9:00 PM
Brain & Bones
Brain & Bones - avatar
+ 1
The Cuber <body> ... <p id="test"><p> ... </body> var score = "12"; document.getElementById("test").innerHTML = score; innerHTML expect the text (string) to assign with it DHANANJAY PATEL
27th Jul 2021, 2:53 AM
DHANANJAY PATEL
DHANANJAY PATEL - avatar
0
you can also use ${score}
27th Jul 2021, 5:48 AM
the gamer boy vishal
the gamer boy vishal - avatar