Created
March 22, 2012 22:07
-
-
Save ethertank/2164986 to your computer and use it in GitHub Desktop.
ショートハンドで記述されたCSSプロパティの値から個別のスタイルを抽出する関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getIndividualCSSPropertyValue = function(prop, propValue, IndividualProp) { | |
var d = document.createElement("div"); | |
d.style[prop] = propValue; | |
return d.style[IndividualProp]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert( getIndividualCSSPropertyValue("margin", "0 10px 20px 30px", "marginLeft") ); // 30px | |
alert( getIndividualCSSPropertyValue("border", "1px solid ghostwhite", "border-color") ); // rgb(248, 248, 255) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment