+ 1
How to write JavaScript with HTML?
I am making my first JS game which will be a simple square, and when you touch it you get a point and you only have so much time.... This is my code... How come the points don’t go up when I touch it?? https://code.sololearn.com/WWHzMDy7uydC/?ref=app
3 Respostas
+ 4
try adding
<span id="counter"></span>
to your html, then in your function add
document.getElementById("counter").innerText = count;
also calling the function inline JavaScript should be
onclick="hi()"
+ 1
You have only 'written' the value - once - to the node, not updating it.
In order to do so, the update has to be included in the click() function to count the value everytime you click.
Also, document.write() will keep previous values on display, I would suggest you use .innerHTML for better visual.
0
i still dont understand