Created
December 9, 2011 19:18
-
-
Save steckel/1452894 to your computer and use it in GitHub Desktop.
A helpful little JQuery plugin I adapted from http://jsfiddle.net/ZcEUL/
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
$.fn.getInlineStyleObject = function() { | |
var $element, prop, props, rprops, str, styleObject, _i, _len; | |
$element = this; | |
str = $element.attr("style"); | |
rprops = /[\w-]+(?=:)/g; | |
props = str.match(rprops); | |
styleObject = {}; | |
for (_i = 0, _len = props.length; _i < _len; _i++) { | |
prop = props[_i]; | |
if ($element[0].style[prop] != null) { | |
styleObject[prop] = $element[0].style[prop]; | |
} | |
} | |
return styleObject; | |
}; |
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
$.fn.getInlineStyleObject = function() { | |
var $element, prop, props, rprops, str, styleObject, _i, _len; | |
$element = this; | |
str = $element.attr("style"); | |
rprops = /[\w-]+(?=:)/g; | |
props = str.match(rprops); | |
styleObject = {}; | |
for (_i = 0, _len = props.length; _i < _len; _i++) { | |
prop = props[_i]; | |
if ($element[0].style[prop] != null) { | |
styleObject[prop] = $element[0].style[prop]; | |
} | |
} | |
return styleObject; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment