示例 :获取第一段的偏移
HTML 代码:
<p>Hello</p><p>2nd Paragraph</p>jQuery 代码:
var p = $("p:first");
var position = p.position();
$("p:last").html( "left: " + position.left + ", top: " + position.top );
结果:
<p>Hello</p><p>left: 15, top: 15</p>
示例 :获取第一段的偏移
HTML 代码:
<p>Hello</p><p>2nd Paragraph</p>jQuery 代码:
var p = $("p:first");
var position = p.position();
$("p:last").html( "left: " + position.left + ", top: " + position.top );
结果:
<p>Hello</p><p>left: 15, top: 15</p>
转载于:https://www.cnblogs.com/GeorgeWang/archive/2011/02/20/1959002.html