Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!