2011-12-11 84 views

回答

3

你的代码是错误的。 jQuery的偏移量是相对做文档的。将您的javascript更改为:

$(document).ready(function(){ 
    $('#child').click(function(){ 
     alert($(this).offset().top); 
    }); 
}); 
0

您的示例不使用.offset()...它使用DOM元素的offsetTop。我将changed the example设置为.offset(),它与预期的文档相关。