
正文
javascript获取标签样式(获取背景为例)
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
function getStyle(el){
if(window.getComputedStyle){
return window.getComputedStyle(el,null);
}
return el.currentStyle;
}
function getStyleValue(el, name){
var style = getStyle(el);
return style[name];
}
console.log(getStyle(document.body));
console.log(getStyleValue(document.body, "backgroundImage"));








