- Joined
- Aug 16, 2022
- Messages
- 54
- Reaction score
- 2
Hi Everybody,
I grabbed this code from like page 20 in a "JavaScript for Dummies" book, but it doesn't work on any browser I have
or in any editor I use:
I can load this into Chrome, Firefox, Edge and I will only see the <h1>Let's count to 10 with JavaScript</h1> line.
The Console tab from the Developer Tools in Chrome tells me:
Uncaught TypeError: document.getElementByID is not a function
What can I do about this? JavaScript is enabled in all of the browsers I use
I grabbed this code from like page 20 in a "JavaScript for Dummies" book, but it doesn't work on any browser I have
or in any editor I use:
JavaScript:
<!DOCTYPE HTML>
<html>
<head>
<title>Hello, HTML</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="description" content="">
<meta name="keywords" content="">
<script>
function countToTen() {
var count = 0;
while (count < 10) {
count++;
document.getElementByID("theCount").innerHTML +=count + "<br>";
}
}
Code-Line Before Listing Code
</script>
</head>
<body onload="countToTen();">
<h1>Let's count to 10 with JavaScript</h1>
<p id="theCount"></p>
</body>
</html>
I can load this into Chrome, Firefox, Edge and I will only see the <h1>Let's count to 10 with JavaScript</h1> line.
The Console tab from the Developer Tools in Chrome tells me:
Uncaught TypeError: document.getElementByID is not a function
What can I do about this? JavaScript is enabled in all of the browsers I use