I am working on a desktop application with electron, which means, that I am using javascript and other web tools. In this bit of code, I am trying to read a boolean from localStorage and writing it to the checked attribute of an HTML-checkbox: devtools = document.getElementById('dev-tools-checkbox'); console.log('The saved value: ' + localStorage.getItem('devtools')); devtools.checked = localStorage.getItem('devtools');
The strange thing is, that no matter what the console shows the logged value as, the checkbox always gets set to true. When reversing the input like this devtools.checked = !localStorage.getItem('devtools');
the value is always false. I have checked that the right value is set, and the logged value is correct.
When I set the following: devtools.checked = false;
it correctly sets the value to false. Same with devtools.checked = true
.
Any clue as to where the always true value is coming from would be greatly appreciated. If you need any more information, just ask.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire