获取元素的CSS样式属性值 IE兼容写法

/**
* 获取元素的CSS样式属性值
*/
function css(element, attrName) {
  /*if (window.getComputedStyle)
  return window.getComputedStyle(element)[attrName]
  return element.currentStyle[attrName];*/

  return window.getComputedStyle ? getComputedStyle(element)[attrName]: element.currentStyle[attrName];
}

猜你喜欢

转载自www.cnblogs.com/kdiekdio/p/10240842.html