获取类名 封装 getStyle
div{ width:100px; height:100px; background:red; }
<div></div>
<script type="text/javascript"> var oDiv = document.getElementsByTagName("div")[0]; oDiv.style.cssText = "width:100px;height:100px;background:red;"; // alert(oDiv.style.width); function getStyle(obj,attr){ if(obj.currentStyle){ return obj.currentStyle[attr]; }else{ return getComputedStyle(obj)[attr]; } } alert(getStyle(oDiv,"width")); var time1 = setInterval(function(){ alert(1); },1000) var time2 = setTimeout(function(){ alert(2); },1000) clearInterval(time1); clearTimeout(time2); </script>