大家好,又见面了,我是你们的朋友全栈君。
注意:getComputedStyle是firefox中的,
currentStyle是ie中的.
比如说
<style>
#mydiv {
width : 300px;
}
</styke>
则:
var mydiv = document.getElementById(‘mydiv’);
if(mydiv.currentStyle) {
var width = mydiv.currentStyle[‘width’];
alert(‘ie:’ + width);
} else if(window.getComputedStyle) {
var width = window.getComputedStyle(mydiv , null)[‘width’];
alert(‘firefox:’ + width);
}
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/126441.html原文链接:https://javaforall.net