$('a').click(function(){ $(this).html(''); //元素距离文档顶部 $(this).append($('div').offset().top+"") //元素距离浏览器顶部 $(this).append($('div').offset().top-$(window).scrollTop()+""); //子元素距离父元素的距离 $(this).append($('p').offset().top-$('div').offset().top); })