Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of offset,client and scroll in js

Shulou Source: shulou.com Published: 2022-06-03 20:08:52 11月12日 Update

This article mainly introduces what is the use of offset,client and scroll in js, it has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Summary of three series of js elements offset,client and scroll

1mement.offsetWidth: including padding and borders

2 scrollWidth element.clientWidth: includes padding, does not contain borders, and will overflow the box if the content exceeds it.

3Give element.scrollWidth: no borders

Main usage:

1 ~ (1) offset series is often used to obtain the element position offsetLeft offsetTop

2 clientWidth client is often used to get element size, size, and clientHeight

3 scrollTop scrollLeft is often used to get the rolling distance.

4. Note that the page scrolling distance is obtained through window.pageXoffset window.pageYoffset.

Thank you for reading this article carefully. I hope the article "what is the use of offset,client and scroll in js" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles elements borders three value location interest content at the same time size time more friends boxes knowledge editing industry information information channels pages Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information Shulou Tech Info Xiaomi Linux