当前位置:网站首页>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
边栏推荐
- 2021-09-18
- Leak detection and vacancy filling (IV)
- input文件上传
- Node data flow
- Promise(三)
- New type of dark energy could solve Universe expansion mystery
- 常用网站汇总
- .Net Core 下使用 Quartz —— 【5】作业和触发器之触发器的通用属性和优先级
- C# Task.Delay和Thread.Sleep的区别
- The time format is incorrect, and an error is reported when running the SQL file
猜你喜欢
随机推荐
1-4 NodeJS的安装之配置可执行脚本
Promise(一)
常用网站汇总
Router对象、Route对象、声明式导航、编程式导航
postMan 传参总结
C# webpai 路由详解
【代码解析(5)】Communication-Efficient Learning of Deep Networks from Decentralized Data
freeCodeCamp----budget & category 练习
JS手写兼容性事件绑定
PHP background parsing after JQ serialization
freeCodeCamp----prob_calculator练习
Leak detection and vacancy filling (V)
七牛上传图片(前台JS+后台C#API获取token)
Kids and COVID: why young immune systems are still on top
浏览器工作原理与实践
Promise(二)
The difference between VaR, let and Const
【Markdown笔记】
手动实现call,apply,bind函数
Promise(四)









