Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The JavaScript:: 1. var $ = function(id) { 2. return document.getElementById(id); 3. }; 4. var timer; 5. var counter = 10; 6. var updateCounter =
The JavaScript::
1. var $ = function(id) {
2. return document.getElementById(id);
3. };
4. var timer;
5. var counter = 10;
6. var updateCounter = function() {
7. counter--;
8. $("counter").firstChild.nodeValue = counter;
9. if (counter <= 0) {
10. clearInterval(timer);
11. document.getElementById("counter").innerHTML = "Blastoff!";
12. }
13. };
14. window.onload = function() {
15. timer = setInterval ( updateCounter, 1000 );
16. };
The HTML:
Countdown: 10
The timer in this code will update the counter???
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started