I read that offsetLeft and offsetTop do not work properly in all browsers. jQuery.offset() provides an abstraction to provide the correct xbrowser value.
What I'm trying to do is get the coordinates where the element was pressed relative to the upper left corner of the element.
The problem is that jQuery.offset().top actually gives me a decimal value in FFX 3.6 (in IE and Chrome, both values โโare the same).
This fiddle demonstrates the problem. If you click on the bottom image, jQuery.offset().top will return 327.5 and offsetTop will return 328.
I would like to think that offset() returns the correct value, and I should use it because it will work in all browsers. However, people obviously cannot click on the decimal points of pixels. Is the correct way to determine the true offset for the Math.round() offset that jQuery returns? Should I use offsetTop or some other method completely?
javascript jquery offset
Explosion Pills Jul 21 2018-11-21T00: 00Z
source share