当前位置:网站首页>Get DOM element location information by offset and client
Get DOM element location information by offset and client
2022-04-23 06:53:00 【zjLOVEcyj】
offset Get the width, height and offset of the element
- offsetTop Gets the distance that the upper part of the element is offset from the parent element with positioning , If none of the parent elements are positioned, the relative value is returned body Distance of
- offsetLeft Work with offsetTop
- offsetParent Returns the parent element with the location of the element , If none of the parent elements has a location, return body
- offsetWidth Returns the element width , Include padding, Frame , The width of the content area
- offsetHeight Work with offsetWidth
offset And style The difference between
The most obvious difference is offset The obtained property value is a read-only property , Cannot be used to modify the size and offset of the element itself , Is a numerical value without units
and style The property value obtained is the read-write property , It can be used to modify the size and offset of the element itself
Besides ,style Only the style attributes specified by the element in the inline style can be obtained , and offset You can get the attributes specified by the element in any way
Click the event to obtain the mouse coordinates
- e.pageX You can get the distance from the mouse of the click event to the left of the page
- e.pageY You can get the distance from the mouse of the click event to the top of the page
client Get the element border and width and height
- clientTop Get the top border size
- clientLeft Get the size of the left border
- clientWidth Get the element width , No borders
- clientHeight Get element height , No borders
scroll Get scroll information
- scrollTop Get the upper distance of the element being rolled away
- scrollLeft Returns the distance to the left of the element being rolled away
- scrollWidth Gets the width of the element itself No borders
- scrollHeight Get the height of the element itself No borders And clientHeight The difference is that , When the element content overflows ,scrollHeight Or return the height containing the overflow content , and clientHeight Will not be
Get the scrolling distance of the page
- window.pageXOffset Get the rolling distance on the whole page
- window.pageYOffset Get the right scrolling distance of the whole page
版权声明
本文为[zjLOVEcyj]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230555334067.html
边栏推荐
猜你喜欢
随机推荐
Batch modify / batch update the value of a field in the database
oninput 一个函数达到控制多个oninput的效果(将本输入框的内容作为参数)【很实用,很实用】
leetcode刷题之二进制求和
.Net Core 下使用 Quartz —— 【4】作业和触发器之作业属性和异常
.Net Core 下使用 Quartz —— 【6】作业和触发器之触发器的日历
Devexpress Gridview 添加全选列
Decentralized Collaborative Learning Framework for Next POI Recommendation
Sum (if) in MySQL_ Sum (if ()) in MySQL
【代码解析(7)】Communication-Efficient Learning of Deep Networks from Decentralized Data
Installing redis using a small leather panel in the window environment
Parse PSD files and map them into components
数据可视化进一步学习
【代码解析(3)】Communication-Efficient Learning of Deep Networks from Decentralized Data
Header内置对象
Kids and COVID: why young immune systems are still on top
浏览器工作原理与实践
mysql中sum (if)_mysql 中sum (if())
深入理解控制反转和依赖注入
Jenkins搭建与使用
Method of MySQL password expiration









