I have an element on a page about 150 pixels down the screen. This is different in different browsers so I want to auto scroll the page to the top of an element that is about 150 pixels down the page. How do I determine what the location of that element relative to the top of the page?
I am trying this but it isn’t working. offset() is returning null.
var positionOfLiveMapTop = $(mapElem).offset().top;
Make sure that mapElem is set. Your problem is most likely that it’s not global and is undefined in the context you’re using it in.