[jQuery] Re: offSetTop offsetLeft return NULL
offsetLeft and offsetTop are properties of a DOM element, not a jQuery object. A jQuery object does have an offset() method which returns an object containing left and top properties, e.g. var offset = jQuery(a).eq(index).offset(); var e_ox = offset.left; var e_oy = offset.top; Note that these are relative to the *viewport* - not the same values you'd get from the offsetLeft and offsetTop properties. If you want those, you can can get them directly from the DOM element: var element = jQuery(a)[index]; var e_ox = element.offsetLeft; var e_oy = element.offsetTop; -Mike I have these functions: var e_w = jQuery(a).eq(index).width(); var e_h = jQuery(a).eq(index).height(); var e_ox = jQuery(a).eq(index).offsetLeft; var e_oy = jQuery(a).eq(index).offsetTop; the first 2 return numbers such as 50 and 100. But the last 2 each return NULL. Why are they returning NULL? How can I get the offset of an element given it's index in terms of a tags?
[jQuery] Re: offSetTop offsetLeft return NULL
Dan, Try: var e_ox = jQuery(a).eq(index).offset().left; var e_oy = jQuery(a).eq(index).offset().top; HTH, Carl On Jul 3, 11:49 am, Dan [EMAIL PROTECTED] wrote: I have these functions: var e_w = jQuery(a).eq(index).width(); var e_h = jQuery(a).eq(index).height(); var e_ox = jQuery(a).eq(index).offsetLeft; var e_oy = jQuery(a).eq(index).offsetTop; the first 2 return numbers such as 50 and 100. But the last 2 each return NULL. Why are they returning NULL? How can I get the offset of an element given it's index in terms of a tags?