【difference of top and left between Javascript and Jquery】教程文章相关的互联网学习教程文章

difference of top and left between Javascript and Jquery

1, top and left relative to the document jquery .offset()Get the current coordinates of the first element, or set the coordinates of every element, in the set of matched elements, relative to the document.var top = $('#elementID').offset().top; var left = $('#elementID').offset().left; native javascript getBoundingClientRect, top-left relative to the top-left of the viewport.var viewportOffset = ...