fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ x=$("p").position(); $("#span1").text(x.top); $("#span2").text(x.left); }); }); </script> </head> <body> <div style="border:1px solid black;padding:100px;margin:50px;"> <p>这一段的位置(相对于它的父元素)是<span id="span1">x</span> top 和 <span id="span2">x</span> left.</p> <button>获取位置</button> </div> </body> </html>
运行结果