window.onload = function() else
console.log(width);
}
var width = window.getcomputedstyle(div)["width"];
var width = div.currentstyle.width;
// json遍歷
var opation =
for (var i in opation)
function getcss(obj, opation) else
console.log(k)}}
console.log(getcss(div, ));
width
100px
height
200px
目前仍存在問題,ie瀏覽器中駝峰命名法時輸入無法獲取,需要借助正則知識以及字串拼接的方法,我將在下面一片文章介紹!window.onload = function() else
return k;
}console.log(getcss(div, "width"));
}
希望我的分享對你有幫助,謝謝!
獲取計算後樣式的方法(相容版)
標準下獲取計算後樣式getcomputedstyle el attr ie下獲取計算後樣式el.currentstyle attr 相容版封裝函式 function getstyle el,attr return getcomputedstyle el attr 注 el 元素 attr 屬性名稱 ...
計算後的樣式
一 高階瀏覽器和低階瀏覽器的不同寫法 w3c制定的標準 api,所有 現代瀏覽器 包括ie9,但不包括之前的版本 都實現了 window.getcomputedstyle 該方法接收乙個要進行樣式計算的元素,並返回乙個 樣式物件 樣式物件 提供了getpropertyvalue 的方法,用於檢索特定...
計算後樣式
1,高階瀏覽器和低階瀏覽器的不同寫法。現在我們只能得到行內的樣式,事實上dom提供了可靠的api,得到計算後的樣式。w3c制定的標準api所有現代瀏覽器 包括ie9,但不包括之前的版本 都實現了window.getcomputedstyle 該方法接受乙個要進行樣式計算的元素,並返回乙個樣式物件。樣...