I apologize if this is a really dumb question but its driving me crazy. When posting this question there were duplicate questions but the answer that the element "section" in my case does not exist is not valid because the element exists.
<script>
for(var i=0; i < 45;i++) {
var div = document.createElement("div");
div.onClick = function() {
alert("you clicked on a box #" + i);
};
document.getElementsByTagName('section')[0].appendChild(div);
}
</script>
<title>Let Keyword</title>
</head>
<body>
<header>
<h1>Click on a box</h1>
</header>
<section></section>
</body>
</html>