getBoundingClientRect()。top和offsetTop有什麼區別?getBoundingClientRect()。top和offsetTop之間的區別?
https://codepen.io/anon/pen/bWZWQg
const elem = document.querySelector('#find');
console.log('getBoundingClientRect: ' + elem.getBoundingClientRect().top);
console.log('offsetTop: ' + elem.offsetTop);
// Stuff to push the div down the page
<div id='find'>Find me</div>
從我的快速測試,唯一的區別似乎是小數的個數返回。