Usage of offsetleft,scrollleft,offsettop,scrolltop in JavaScript

Source: Internet
Author: User

, ScrollHeight: Gets the scroll height of the object, the actual height of the object
2,scrollleft: Sets or gets the left distance between the left edge of an object and the current visible content in the window
3,scrolltop: Sets or gets the distance between the top of the object and the topmost part of the visible content in the window
4,scrollwidth: Gets the scrolling width of the object
5,offsetheight: Gets the height of the object relative to the parent coordinate specified by the parent coordinate offsetparent property
6,offsetleft: Gets the distance from the current object to the left of its parent layer
7,offsettop: Gets the distance from the current object to the top of its parent layer.
8,event.clientx the horizontal coordinates of the relative document
9,event.clienty vertical coordinates relative to document
The horizontal coordinates of the 10,event.offsetx relative to the container
The vertical coordinates of the 11,event.offsety relative to the container
12,document.documentelement.scrolltop The vertical scrolling value
13,event.clientx+document.documentelement.scrolltop relative to the document's horizontal coordinates + vertical scrolling amount
14,clientleft returns the distance between the Offsetleft property value of an object and the true value to the left of the current window

The following picture may help you to better understand:

Specific usage--examples:

The code is as follows Copy Code
function Getabsleft (e) {
var l=e.offsetleft;
while (e=e.offsetparent) L+=e.offsetleft;
return l;
}
var e = document.getElementById ("Liuxiaofan");
Getabsleft (e);

Special Note: Here used E to pass the value of the function only through the getElementById method, with jquery $ ("#liuxiaofan") invalid.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.