<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
#div2{
width:400px;
height:400px;
background:#0f0;
margin-left:10px
}
#div3{
width:300px;
height:300px;
background:#00f;
margin-left:10px
}
#div4{
width:200px;
height:200px;
background:#000;
margin-left:10px;
}
</style>
</head>
<div id="div2">
<div id="div3">
<div id="div4"></div>
</div>
</div>
</html>
console.log($("#div4").offset());
console.log(document.querySelector("#div4").offsetLeft)
console.log($("#div4").offset());
console.log(document.querySelector("#div4").offsetLeft)