fe-interview
fe-interview copied to clipboard
[js] 第313天 如何用jst获取DOM元素在页面中的绝对位置?
- 递归获取
function getTop(e){ var offset=e.offsetTop; if(e.offsetParent!=null) offset+=getTop(e.offsetParent); return offset; } - 参考
Element.getBoundingClientRect().x Element.getBoundingClientRect().y