Home >Web Front-end >JS Tutorial >What are the ways to get element offset in javascript_javascript tips
The offset of the element can be obtained through four attributes:
1. offsetHeight: The size of the space occupied by the element in the vertical direction, (pixels). This includes the height of the element, the height of the (visible) horizontal scroll bar, the height of the top border, and the height of the bottom border.
2. offsetWidth: The size of the space occupied by the element in the horizontal direction, (pixels). Includes the width of the element, the height of the (visible) vertical scrollbar, the height of the left border and the height of the right border.
3. offsetLeft: the pixel distance between the left outer border of the element and the left inner border of the containing element;
3. offsetTop: the pixel distance between the top outer border of the element and the top inner border of the containing element;