Search code examples
jquerycsscomputed-style

How to get the authored style properties of an element?


I am using jQuery to animate elements on my page.

In order to re-initialize the position of all my elements at the end, I need to get the authored properties of my elements, specified in % in my stylesheet.

I first used the .css() function but it is giving me the computed value, which I don't want. I am looking for the values I declared in the CSS (percent or pixels).

Any ideas on how to get that?


Solution

  • The solution is to use .position() instead of .css('top') or .css('left'), then convert the values into percents.