元素页面位置[left,top]获取
2012-09-19 09:23 江苏黑马 阅读(237) 评论(0) 编辑 收藏 举报var getCanvasPos = function(canvas) { var left = 0; var top = 0; // 元素在页面的位置left和top while (canvas.offsetParent) { left += canvas.offsetLeft; top += canvas.offsetTop; canvas = canvas.offsetParent; } return [left, top]; }