I am struggling with a little javascript.
I have these four lines:
var footer = document.getElementById('footer');
var cookieBanner = document.createElement('div');
cookiebanner.className = "cookieBanner";
footer.appendChild(cookiebanner);
But in console I get
Uncaught TypeError: Cannot read property 'appendChild' of undefined
If I do the same in console, it works. Why would that be?