js获取css属性值
作者:
WangYatao | 来源:发表于
2017-07-30 18:13 被阅读14次<body>
<p id=”qq” class=”ss” >sdf</p>
<script type=”text/javascript”>
function GetCurrentStyle (obj, prop) {
if (obj.currentStyle) {
return obj.currentStyle[prop];
}
else if (window.getComputedStyle) {
propprop = prop.replace (/([A-Z])/g, “-$1”);
propprop = prop.toLowerCase ();
return document.defaultView.getComputedStyle (obj,null)[prop];
}
return null;
}
var dd=document.getElementById(“qq”);
alert(GetCurrentStyle(dd,”width”));
</script>
</body>
本文标题:js获取css属性值
本文链接:https://www.haomeiwen.com/subject/ywdklxtx.html
网友评论