handleman
7/24/2014 - 10:25 AM

very simple (probably in much need of improvement) Jquery plugin I've thrown together that will get you the value of an inline style propert

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");