Reputation: 608
I have the following element with its inline css:
<div class="collection" style="top: -482px;"></div>
How can I get the top
value that is set with inline css?
I know of offset
but that returns the coordinates relative to the document as far as I know, what I need is the element's specified top position.
Upvotes: 0
Views: 328
Reputation: 2130
Var x=$(".collection").position(); alert("Top: " + x.top + " Left: " + x.left);
This will give exact position values.
Upvotes: 0
Reputation: 1961
A nother aproach:
var styles = $('.collection').attr('style').split(';');
alert(styles[0]);
I'm creating an array of the inline styles and alert the first one.
UPDATE:
Upvotes: 1
Reputation: 1236
To get an element's CSS property, use the jQuery method .css()
. Here's a fiddle to demonstrate its use.
Upvotes: 2