how to fix this error Cannot read property of null (reading 'style')
when i used JavaScript code
var boxElement = document.querySelector('popover-bottom')
boxElement.style.display = 'none';
this error occurred with me
"Cannot read property of null (reading 'style') "
how can fix it
Hi Andrew,
he's just saying that boxElement is null.
That is always (or at least often) a possibility, so you should check for that before doing something with your variable.
So why is it null in your case ? You are intending to find first element with a given class, but you are not using a class selector. it should be
var boxElement = document.querySelector('.popover-bottom')
Dorine