I may be wrong on this but I think it should be:

f...n findHeight elem, bottomPad
   var height = 0;
   var windowHeight = $(window).height();
   var elemOffset = $(elem).offset();
   var elementTop = elemOffset.top;                            // <- you
stick .top on the end instead of ['top']
   height = windowHeight - elementTop - bottomPad;
   return height;

On 07/10/2007, jarrod <[EMAIL PROTECTED]> wrote:
>
>
>
> I'm finding that the Dimensions plugin sometimes doesn't return the "top"
> position of an element, just returns zero. (Sometimes works perfectly
> though.)
>
> Here is my code, sanitized for the forum software.
>
> // Finds the height that an element should be to be X number of pixels
> from
> the
> // bottom of the window using JQuery Dimensions plugin.
> f...n findHeight elem, bottomPad
>     var height = 0;
>     var windowHeight = $(window).height();
>     var elemOffset = $(elem).offset();
>     var elementTop = elemOffset['top'];
>     height = windowHeight - elementTop - bottomPad;
>     return height;
>
> What happens is that sometimes the elemOffset just turns out to be 0, 0,
> 0,
> 0 even though the element is pushed down in the window. I've tried setting
> "relativeTo body" but that doesn't help.
>
> Background: I'm trying to the bottom of some element is always 20 px from
> the bottom of the window. I don't want to use absolute positioning on this
> particular element because that would mess up a bunch of other things. I'm
> trying to calculate element height that would put the bottom where I want
> it.
>
> Any help would be greatly appreciated.
>
> Thanks!
>
> E
> --
> View this message in context:
> http://www.nabble.com/Dimensions-plugin%2C-offset-%27top%27--returns-0-regardless-of-position-tf4581708s27240.html#a13078975
> Sent from the jQuery General Discussion mailing list archive at Nabble.com
> .
>
>


-- 
Kind Regards,
Alex Bilbie

Freelance website and graphics design
Quite Good Media Ltd

m: 07923 272797

Reply via email to