利用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函数