Printing Real-Time Game Data to the Screen (part 2)
Now we can access our new text 'div' elements through our JavaScript file, 'tempGame.js'. First we must create a couple of variables that hold references to the new 'div' text elements back on our webpage. This is how it's done: var debugText1 = document.getElementById("debug1"); Using the 'var' keyword, we create a variable called 'debugText1' that will hold the handle or reference to a text element. But which webpage text element - there could be hundreds? Well, remember back in part 1 of this post, inside our HTML file 'example01.html' we created a 'div' element and gave it an 'id' named "debug1". In case you forgot, here is the line taken from 'example01.html' : <div id="debug1" style="position:fixed; left:5%; top:4%; color:grey;"> .... This is our target div that we want. How do we access it from our 'tempGame.js' file when it's located o...