如何從元素(不包括值)中獲取當前應用的CSS
屬性標識符?獲取應用的css屬性標識符
或者說:如何獲取元素translate
,skew
,rotate
或rect
?我不是指完整的返回字符串,如:rect(300px 0px 0px 300px)
。我的意思只是property-identifiers
...
我不是很熟悉RegExp,但也許可以做到這一點?
所以爲了更好的詮釋用途:
我需要檢查的是,改變一些值(通過矩陣陣列),並再次重新申請他們回到元素。
// http://stackoverflow.com/a/5968313/1250044
function matrixToArray(matrix) {
return matrix.substr(7, matrix.length - 8).split(', ');
}
$("#foo").css("clip","rect(300px 0px 0px 300px)");
var matrix = matrixToArray($("#foo").css("clip"));
// If `#foo` has something else
// applied than `clip`, then
--- ˅ --- // is that not really dynamically
$("#bar").css("clip", "rect(" + matrix[0] + matrix[1] + matrix[2] + matrix[3] + ")");
您可以使用jQuery進行檢測。 – Morpheus
@Pete閱讀我的問題,我需要沒有價值的財產...... – yckart
也許這將幫助你http://stackoverflow.com/questions/1004475/jquery-css-plugin-that-returns-computed-style-of-元素 - 僞 - 克隆 - 那 - el – Morpheus