利用currentStyle()和ComputedStyle()

1 通常用法:

balance为类名

window.getComputedStyle(document.querySelector(".balance"), null).backgroundColor;

window.getComputedStyle(document.querySelector(".balance"), null).fontSize;

 

2 封装一个函数:

function getstyle(obj, key) {

    if (obj.currentStyle) {

        return  obj.currentStyle.key;

    } else {

        Return  getComputedStyle(obj, mull).key;

    }

}

封装进getstyle函数

 

相关文章:

  • 2021-11-19
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
猜你喜欢
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-08-05
  • 2021-04-05
相关资源
相似解决方案