var foo =$('#divname').css('top');
var bar = $('#divname').css('marginTop');

Be careful with padding though, because I think different browsers
report it in different ways because it is a sort of shorthand for
padding-top + padding-right + ...etc. As such, just asking for $
('#divname').css('padding') may not always return what you might
expect. It is safer to get each one separately ... $
('#divname').css('paddingTop'); etc. Of course, if you're sure they're
all set the same then one will do. [same applies to $
('#divname').css('margin');]

On Dec 21, 1:19 am, Jeroen <[EMAIL PROTECTED]> wrote:
> Suppose this piece of css, how would I get the values for top, margin-
> left or padding?
>
> #divname {
>    top: 0;
>    margin-left: 1px;
>    padding: 7px;
>
> }
>
> Setting this is easy:
>
> $(#divname).css('height', '200px');
>
> And getting it also:
>
> var foo = $(#divname).width();
> or
> var foo = $('#divname').get(0).width;
>
> However  top, margin etc. I don't how to fetch it. Probably very
> obvious problem but seem to overlook it.
> Thanks in advance!
>
> ---
> Jeroen

Reply via email to