The following error is being thrown in Google Chrome\'s developers tools:
Uncaught TypeError: Cannot read property \'className\' of undefined
It's throwing this error because when dom first loads you were using before declare.
for this error i had one solution written below:
you can add if condition particular element is not undefined like below
if(document.getElementsByTagName('button') !== undefined){
// and write your needed code here
}