Posted By

jatkins on 10/26/10


Tagged

html elements positioning


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


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  

You need to login to post a comment.