Ultra noob question
I have variable in JavaScript and I have to use it in HTML multiple times
I've tried using document.getElementById("").innerHTML = x, but that requires ID's, and since they can be used only once, it won't be the best solution because I'm using it a lot of times...
<div>
<h1>Title</h1>
<!-- I want to pass value of x to all of spans bellow -->
<p>Value of x: <span class="value-of-x"></span></p>
<p>Value of x: <span class="value-of-x"></span></p>
<p>Value of x: <span class="value-of-x"></span></p>
</div>
<script>
var x = 100;
</script>
I'm really sorry if it's a dumb question, but I'm struggling with this for a solid hour and nothing works for me
Every suggestion welcome
Edit - typos
document.querySelectorAll()developer.mozilla.org/en-US/docs/Web/API/Document/…