函数语法:currentStyle、getComputedStyle兼容判断

var oDiv = document.getElementById('aa');
if(oDiv.currentStyle){
      var style = oDiv.currentStyle;
     alert('ie:'+style.width)

} else if(window.getComputedStyle) {
      var style = window.getComputedStyle(oDiv);
      alert('谷歌:'+style.width)
}

猜你喜欢

转载自www.cnblogs.com/liubingyjui/p/10234811.html