I'm trying to make Cookie Clicker for a class I'm taking, and I'm tripping up right at the beginning because of document.getElementById. Here's my html (the relevant bits).
<div id="cookiebox">
<input onclick="click()" type="image" src="images/cookie.jpg" class="cookie" />
</div>
<div id="cookieNumber"></div>
Then the corresponding javascript:
var cookies = 0;
function click() {
cookies = cookies + 1;
console.log(cookies);
var test = document.getElementById("cookieNumber").innerHTML = cookies;
}
So what ends up happening is that I get a type error because it doesn't find the cookieNumber div and nothing happens. I'm well aware that this is a super newbie question, but if anyone could help me out with this I would greatly appreciate it.
EDIT: Fixed the issue with the document.getElementById. Still can't get the function to fire though from the input.
EDIT 2: Fixed everything. Thanks @j08691.