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

前端开发   发布日期:2023年05月29日   浏览次数:47

/**
* 获取元素的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];
}

以上就是获取元素的CSS样式属性值 IE兼容写法的详细内容,更多关于获取元素的CSS样式属性值 IE兼容写法的资料请关注九品源码其它相关文章!