<!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>兩個(gè)屬性都不能讀取到,是我的語法錯(cuò)了嗎?ele.currentStyle[attr]語法不是這樣的嗎?
currentStyle在瀏覽器里報(bào)錯(cuò),是我的用法錯(cuò)了嗎?
慕勒小柒
2017-09-03 19:33:28