Similar to this question: get CSS rule's percentage value in jQuery
However, I am writing a plugin and it needs to deal with it gracefully dependent on how the width was originally specified. If the element was originally specified in pixels it is fine as that is the value that .width()
, .innerWidth()
, outerWidth()
and .css('width')
return.
But I want to know if it was original set as a percentage. So that if the container element resizes then I know to recalculate the width that I have set on my element.
Is this possible? The only thing I can think of is trying to loop through document.stylesheets looking for relevant rules but I think that will be more or less impossible to do generically. Any other ideas?
Thanks!
.css('width')
doesn't return the property as a string? How else would you get theauto
value? – Capsular