Friday, March 4, 2011

jQuery offset function not working in IE - top is a IE keyword

The following piece of code is working fine in FF, Chrome, Opera but not in IE.  The error I got in IE says line 2 is 'Not Implemented'

left = $("#myElement").offset().left - 120;
top = $("#myElement").offset().top;     

It turns out that 'top' is a IE keyword. By saying top = ***, it implies set top position to ***, and this = operation is not implemented in IE.
So changed top to something else solved the problem.

This code is working in all browser:

rLeft = $("#myElement").offset().left - 120;
rTop = $("#myElement").offset().top;            

1 comment :

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from JQuery Training . or learn thru ES6 Online Training India. Nowadays JavaScript has tons of job opportunities on various vertical industry.