实例 jQuery 如何设置元素的偏移坐标

x
 
<!DOCTYPE html>
<html>
<head>
<script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").offset({top: 200, left: 200});
  });
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<button>Set the offset coordinates of the p element</button>
</body>
</html>
                    

输出结果