Skip to content

Instantly share code, notes, and snippets.

@handleman
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save handleman/349f363bfc90963eb317 to your computer and use it in GitHub Desktop.

Select an option

Save handleman/349f363bfc90963eb317 to your computer and use it in GitHub Desktop.
very simple (probably in much need of improvement) Jquery plugin I've thrown together that will get you the value of an inline style property
(function ($) {
$.fn.inlineStyle = function (prop) {
var styles = this.attr("style"),
value;
styles && styles.split(";").forEach(function (e) {
var style = e.split(":");
if ($.trim(style[0]) === prop) {
value = style[1];
}
});
return value;
};
}(jQuery));
//Returns value of "width" property or `undefined`
//var width = $("#someElem").inlineStyle("width");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment