获取元素距页面顶部的距离

  • Post author:
  • Post category:其他


function getElementTop (el) {

  var actualTop = el.offsetTop

  var current = el.offsetParent

  while (current !== null) {

    actualTop += current.offsetTop

    current = current.offsetParent

  }

  return actuanlTop

}



版权声明:本文为lj_qmzhnT_T原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。