Categories: Report an Issue : Linux :

element properties not being correctly reported in javascript

Showing 1-1 of 1 messages
element properties not being correctly reported in javascript ooobleck 6/1/12 12:53 PM
I'm experiencing a problem with a DOM element, call it "el". In my javascript, I ask for el.offsetTop and I get 0. That can't be right, since it's down  a ways in the div.

So, I went into the debugger, and opened the Elements panel, and the offsetTop property shows 162. Cool, about what I expected.

In the console panel, if I type el.offsetTop, I get 0.
If I type dir(id) for the element's id, it also shows 0 for offsetTop.

So, how come the Elements panel gets it right, but javascript and the console get 0? It's driving me nuts, because in other places on the same web page, offsetTop is correctly returned by javascript.

It's just a simple <span> element inside a <div>. The same nesting elsewhere on the page works fine.