Uncaught TypeError: Cannot read property 'className' of undefined

后端 未结 7 1705
春和景丽
春和景丽 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
    }
    
    0 讨论(0)
提交回复
热议问题