document.querySelector always returns null

前端 未结 4 1732
野的像风
野的像风 2021-01-20 01:38

I\'ve looked at the other answers but still don\'t understand.

For some reason this line of code always returns null.

var els = document.querySelecto         


        
4条回答
  •  余生分开走
    2021-01-20 02:10

    I don't know your full javascript code but maybe you are create/append that element after the script loads or something like that and therefor querySelector don't find the element with that id. Check your scope or write the code here if you suspicious of that kind of error.

提交回复
热议问题