I have this tiny bit of code here, but it is not functioning when I reload the page, as I get the error
TypeError: document.getElementById(...) is null
document.getElementById('devMode_checkbox').checked = false;
The line(s) the error is referring to is as follows:
checkDevMode();
function checkDevMode() {
var devModeIsTrue = getCookie('devModeIsTrue');
if (devModeIsTrue === true) {
document.getElementById('devMode_checkbox').checked = true;
enableDevMode(devModeIsTrue);
} else {
document.getElementById('devMode_checkbox').checked = false;
}
}
I have quadruple checked the id of the element
<input type='checkbox' onchange='enableDevMode(this.checked)' id='devMode_checkbox'>
and I don't really have a good understanding nor a solution for this problem. Also I could not find a working solution for this. (Sorry if this is a duplicate, but non of the given answers worked for me)
Is there a (proper) solution to this?