+ 2

How do I set the text in a h1/text/marquee to a javascript variable?

I have been trying to make a simple clicker game and I dont think there should be a popup every time..

10th Jun 2020, 10:36 AM
AtoMiC G00TZ
2 Answers
+ 3
I don't really get what you mean but hopefully this helps you <h1>click me</h1> <script> var a=document.getElementsByTagName("h1")[0]; a.addEventListener("click",function(){ alert("you won"); }) </script>
10th Jun 2020, 10:42 AM
Abhay
Abhay - avatar
0
I want to make it so that if you click a button, instead of showing a pop up with your number and no way to memorize it, I want to change the H1 text to a JS variable. For example, you click the button and the number of clicks shows in a pop up. But I want it to show in a H1 with it changing every time it is updated.
15th Jun 2020, 3:18 AM
AtoMiC G00TZ