I'm creating a website where I'll be displaying my work. Then I noticed that I needed a Cookie Notice. Because I want to make it 100% by myself (without generators, etc.) I started creating it. The Cookies themselves are working fine, but main.js is not registering the button's onClick.
Here's the code:
var acceptButton = document.getElementById("cookieAccept");
acceptButton.onclick = function() {
    alert("HELLO");
}
My button's code:
<button id="cookieAccept" class="cookieButton">Accept</button>
I've been Googling a lot, searching through StackOverflow, etc. There are no answers that worked for me (yet). Here are the solutions I tried:
- jQuery
- object.onclick = function() {}
- object.addEventListener("click", false);
- Put the object.addEventListener("click", false)inside ofwindow.onload
Any hints/help? - XaafCode
EDIT
Console error:
Uncaught TypeError: Cannot set property 'onclick' of null
 
     
     
    