<html>
<head>
<title>Return Width</title>
<style type="text/css">
#foo { background: green; width: 80px; }
</style>
<script type="text/javascript">
function getWidth() {
alert(document.getElementById("foo").style.width);
}
</script>
</head>
<body>
<div id="foo" onClick="getWidth()">
Hello World
</div>
我一直在尝试返回几个属性,包括width
andbackgroundColor
我发现我可以设置属性但我不能返回它们。为什么?