" en " >
" UTF-8 " >
获取非行间样式
#div1{height: 200px;width: 200px;background - color: red;}
function getStyle(obj,name){
if (obj.currentStyle){
return obj.currentStyle[name]; //IE浏览器
}
else if (getComputedStyle){ //Firefox,chrome浏览器
return getComputedStyle(obj, null )[name];
}
}
window.onload = function(){
var oDiv = document.getElementById( ' div1 ' );
alert(getStyle(oDiv, ' height ' ));
}
查看更多关于JS获取非行间样式及兼容问题-Web学海无涯的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did115690