0
我有一個JavaScript文件最後加載。在該文件的代碼被執行:未捕獲TypeError不能設置未定義的屬性'top'
var x = document.getElementById("bildfram1").offsetHeight;
document.getElementsByTagName("header").style.top = "calc(x/2)";
但我在控制檯收到此錯誤:
Uncaught TypeError: Cannot set property 'top' of undefined
關於如何解決此問題的任何幫助! 在此先感謝!
的[JavaScript中的潛在重複| Uncaught TypeError:無法設置屬性的'顏色'未定義](http://stackoverflow.com/questions/30232423/javascript-uncaught-typeerror-cannot-set-property-color-of-undefined) –
可能重複[什麼querySelectorAll,getElementsByClassName和其他getElementsBy \ *方法返回?](http://stackoverflow.com/questions/10693845/what-do-queryselectorall-getelementsbyclassname-and-other-getelementsby-method) – Xufox