js获取div相对屏幕的坐标位置

 1:div相对屏幕的坐标位置

    function getDivPosition(div){
        var x = div.getBoundingClientRect().left;
        var y = div.getBoundingClientRect().top;
        return {x:x,y:y};
    }

参数传js原生对象

getDivPosition($('#div0')[0]).x
getDivPosition($('#div0')[0]).y
 
原文地址:https://www.cnblogs.com/JimmyBright/p/5728462.html