Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So we have e = document.getElementById ("output") and now this e variable is that element and we can use a property on that inner HTML to actually change the contents of that output element, and that output element is span in this case, and it has a 0 there, but it'll have different numbers as we increment our counter. So let's go ahead and save this and open it in the browser. I am going to open this in Firefox, and there we have it, and you see, there it is, counting away 1, 2, 3, 4, et cetera.
As I said, this id attribute is often used for stylesheets, and in fact I can come in here and I can say style and I can use it as a CSS selector. And now I can do things to that output element, like for instance I can change its color, make it a little bit reddish. I can give it a background color and I can give it a border. When I save this and load it up in the browser, I'll just hit Reload here. See we start at 0 again when I reload, and there it is.
Well, the reason we don't do that is that that doesn't work. It doesn't work in several browsers that I've tried, in fact off the top of my head I seem to remember it worked in one or two browsers, but I don't remember which ones they were. It definitely does not work in Firefox. So in this case and in this case alone, you need to actually use the begin tag and the end tag, and it needs to be completely empty. You can't do that. It needs to be completely empty. So you notice my source says count.js. If we can open up count.js in our text editor and you can see it's exactly the same code, and when I load this in my browser you'll notice that it works just great.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97472 Viewers
61 Video lessons · 84700 Viewers
71 Video lessons · 68900 Viewers
56 Video lessons · 101346 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.