-4

I'm actually trying to use a js var in my html code like this :


In javascript code :

var test = 'This is a test';

And in the html :

<p>display var test here</p>

How can I display the value of my js var in html like this ?

Leo Bonn.
  • 1
  • 5

1 Answers1

0

HTML:

<p id="paragraph"></p>

JavaScript:

var test = 'This is a test';
document.getElementById('paragraph').innerHTML = test;
Santhosh V
  • 380
  • 1
  • 11