Posted By

jatkins on 10/26/10


html elements positioning

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Check if an element is vertically between two other elements

 / Published in: JavaScript

Public domain.

  1. function betweenElements(firstElement, secondElement, thirdElement) { // return true if thirdElement is between firstElement and secondElement
  2. return document.getElementById(thirdElement).offsetTop > document.getElementById(firstElement).offsetTop &&
  3. document.getElementById(thirdElement).offsetTop + document.getElementById(thirdElement).offsetHeight <
  4. document.getElementById(secondElement).offsetTop + document.getElementById(secondElement).offsetHeight;
  5. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: on September 9, 2018

root alcatel 5044r

You need to login to post a comment.