ncaught TypeError: Cannot read property 'addEventListener' of null code example
Example 1: Uncaught TypeError: Cannot read property 'addEventListener' of undefined
1)Check you placed .before the class
Example:
document.getElementsByClassName('.yourclassname')
the code should be document.getElementsByClassName('yourclassname');
2)Check the spelling for addEventListener
Example 2: Cannot read property 'addEventListener' of null
if (document.body.contains(document.getElementById('someid'))) {
}
if (!document.visibilityState) {
}
if (!document.getElementsByClassName('.someclass')){
}