Jquery javascript find how far an element with position remains: relative

in jquery / javascript I'm trying to find how far the element with position: relative is left. There are several elements between this and to the left of the screen. since it is positioned: relative and float: left using:

 $(this).css('left');

gives me "0px" every time. So, how do I know how far the item is to the left of the screen?

+3
source share
1 answer

You can use jQuery method .offset().

Here is an example: http://jsfiddle.net/PgbmV/

$(this).offset().left;

This will give a left position relative to the document.

, .position() .

$(this).position().left;
+7

Source: https://habr.com/ru/post/1757375/


All Articles