ITPub博客

首页 > 应用开发 > > 下面这段代码为何alert出来的是空值?

下面这段代码为何alert出来的是空值?

作者:cartoonfish 时间:2019-09-26 10:48:59 0 删除 编辑

<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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    96
  • 访问量
    514