Uncaught TypeError: Cannot read property 'className' of undefined

后端 未结 7 1729
春和景丽
春和景丽 2020-12-31 00:14

The following error is being thrown in Google Chrome\'s developers tools:

Uncaught TypeError: Cannot read property \'className\' of undefined

7条回答
  •  长发绾君心
    2020-12-31 00:36

    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
    }
    

提交回复
热议问题