要获得css元素中的计算样式(即经过层叠之后,最终的样式),支持W3C的浏览器可以使用document.defaultView.getComputedSyle方法。该方法接受两个参数,第一个参数为要获得样式的元素,第二个参数为一个伪元素字符串(例如:":after",如果没有,就置为null)。该方法返回一个StyleSheetDeclaration对象,在通过该对象的getPropertyValue(propertyName)获得最终的样式属性值。注意,这里的proprtyName为wrold-world类型(如: background-color)。而IE中使用element.currentStyle[propertyName]方法,注意这里的propertyName为worldWorld类型(如:backgroundColor)。

相关文章:

  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案