Last active
August 29, 2015 14:04
-
-
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
This file contains hidden or 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
| (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