<body> <divstyle="background:#ccc;height:300px;"onclick=""></div> <divstyle="position:relative;"> <divstyle=" position:absolute;left:50px; top:50px;"id="DivID"></div> </div> <scripttype="text/javascript"> var X = $('#DivID').offset().top; var Y = $('#DivID').offset().left; document.write(X+" "); document.write(Y+" "); //获取相对(父元素)位置: var C = $('#DivID').position().top; var D = $('#DivID').position().left; document.write(C+" "); document.write(D); </script> </body> </html>