用css定义一个div,如何用js取得样式的属性呢?比如长宽之类的。
我试着用js 定义样式,没有问题!但要读出属性却不行了。
[html] <style> #d1 { width:200px; } </style> <body> <div id="d1"></div> <script> theD=document.getElementById("d1"); alert(theD.currentStyle.width); alert(theD.offsetWidth) </script> [/html] |