Chu*_*and 0 html javascript css
为什么我在以下代码中的alert()中未定义:
var header = document.getElementById("header");
var navigationBar = document.getElementById("navigationBar");
var buttons = document.getElementsByClassName("button");
alert(header.innerWidth);
alert(navigationBar.innerWidth);Run Code Online (Sandbox Code Playgroud)
.header {
background-color: #263238;
border-bottom: solid 0.25em #37474F;
border-radius: 0;
padding: 0.5em;
display: block;
}
.navigationBar {
display: inline-block;
}Run Code Online (Sandbox Code Playgroud)
<div class="header" id="header" align="right">
<div class="navigationBar" id="navigationBar">
</div>
</div>Run Code Online (Sandbox Code Playgroud)