How to store an HTML element's value to a JS variable?

Hi guys,

As the title suggests.
Below is what I did, and what I get printed on the console. Any suggestions?

The HTML bit

<body>
  <div>
    <p id="stuff">Stuff to store in a JS var</p>
  </div>
  <script src="sw.js"></script>
</body>

The JS bit

let htmlTxt = document.getElementById("stuff").value;
console.log(htmlTxt);

What it prints on the console

I’d appreciate your help very much.
Thank you!

use textContent:

https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent

.value is for value of <input> I think.

1 Like

Thank you!
I finally got my StopWatch to display lapses of time.