簡單獲取目標css的屬性方法 - TerryLee7788/JS_test GitHub Wiki
HTML code
<style>
#terry{ height:172px; }
</style>
<div id="terry">
hihi!~ I'm Terry~
</div>
Javascript code
function getTargetStyle(target, style){
var cur = window.getComputedStyle(target, null).getPropertyValue(style);
return cur;
}
var terry = document.getElementById('terry');
var terry_height = getTargetStyle(terry, 'height');
console.log(terry_height); //172px