JavaScript 获取元素的 坐标位置
document.onmousemove = function(e){ if (!window.angdh_list){ window.angdh_list = []; }; window.angdh_list.push({x:e.clientX,y:e.clientY}) console.log(e.clientX,e.clientY); }
https://blog.csdn.net/im20166456/article/details/113793437?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-2-113793437-blog-79565475.pc_relevant_vip_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-2-113793437-blog-79565475.pc_relevant_vip_default&utm_relevant_index=3
var tag=document.getElementById('id') //该left是获取在相对父元素下的相对x轴坐标 //tag.offsetLeft会计算该标签的margin和padding以及绝对定位属性的长度 //但是无法获取transform内的位移属性 var left=tag.offsetLeft; offsetTop