<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Document</title> <style type="text/css"> div{ background: #33AAC8; padding: 10px; } </style> </head> <body> <div style="width:100px; height:100px;"></div> </body> <script type="text/javascript"> var div=document.getElementsByTagName('div')[0]; console.log(div.currentStyle.padding); console.log(div.currentStyle["background-color"]); </script> </html>
两个属性都不能读取到,是我的语法错了吗?
ele.currentStyle[attr]语法不是这样的吗?
橋本奈奈未
相关分类