Javascript获取Dom元素样式

Javascript获取Dom元素样式

var getStyles = element =>{
	const style = window.getComputedStyle(element,null);
	const width = window.currentStyle ? window.currentStyle : window.getComputedStyle(element,null).getPropertyValue('width');

	console.info(style,width);
}

var dom = document.getElementById('gameCanvas');

const styles = getStyles(dom);

console.log(styles);