Uncaught TypeError: Cannot read property 'style'

js在瀏覽器報出以下錯誤(chrome中):Uncaught TypeError: Cannot read property 'style' of null

瀏覽器若是報出以下錯誤(chrome中):Uncaught TypeError: Cannot read property 'style' of null  請問這錯誤具體是什麼意思?(您須要掌握JS常見錯誤的處理和常見英文報錯的意思) web

 

調用style屬性的object是空的,通常是元素獲取出錯形成的chrome

好比你想用 document.getElementById("text1"),這裏沒有獲取到元素,最好的辦法是瀏覽器

var pa = document.body.querySelector('#pa')獲取元素,然後spa

pa.style.display= "block";orm

相關文章
相關標籤/搜索