Because you haven't set the width. Here is how you get the computed style value of an element:
var computedStyle = function (el,style) {
var cs;
if (typeof el.currentStyle != 'undefined'){
cs = el.currentStyle;
}
else {
cs = document.defaultView.getComputedStyle(el,null);
}
return cs[style];
}
Now let's get the value:
var element = document.getElementById('Img3');
alert(computedStyle(element,'width'));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…