【发布时间】:2011-12-11 10:41:22
【问题描述】:
【问题讨论】:
标签: jquery position offset fixed
【问题讨论】:
标签: jquery position offset fixed
您的代码错误。 jQuery 偏移量是相对于文档的。将您的 javascript 更改为:
$(document).ready(function(){
$('#child').click(function(){
alert($(this).offset().top);
});
});
【讨论】:
您的示例不使用 .offset() ...它使用 DOM 元素的 offsetTop。我 changed the example 到 .offset() 并且它是相对于文档的,正如预见的那样。
【讨论】: