首页 > 应用开发 > > 下面这段代码为何alert出来的是空值?
<html>
<head>
<style type="text/css">
div{width:100px;height:100px;background-color:orange;}
</style>
</head>
<body>
<div id="box">123</div>
<script type="text/javascript">
var box=document.getElementById('box');
var w=box.style.width;
var h=box.style.height;
alert(w);
</script>
</body>
</html>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1409/viewspace-3170131/ ,如需转载,请注明出处,否则将追究法律责任。