Can one use javascript to find if one <div> element is covering/over another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • turgon
    New Member
    • Nov 2008
    • 2

    #1

    Can one use javascript to find if one <div> element is covering/over another

    At the moment I making an ajax based file manager system. Im approched by a tricky problem. As in windows explorer etc I want users to be able to select any free space, click down, and drag a semi-transparent box around that will automaticly select any file/folder elements it covers over.

    In a more general sense, take this tutorial page with the three movable objects. I can lift Item 1 and place it over Item 2. But can I use javascript now, so that it automaticly triggers a function because Item 2 is covering Item 1.

    So basiccaly Im wondering is there any way to determine if one <div> is covering another?? Cheers for any ideas!
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    If all you want is the divs covered by the semi-transparent box, why not check the positions of the divs on mouse up?

    Comment

    • turgon
      New Member
      • Nov 2008
      • 2

      #3
      Well I want the elements to change color as they are highlighted. And doing a co-ordinates comparision of every element with the selecting box every time the mouse moves would be too memory intensive.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Is the instant highlighting a must? If not, you can use transparency and a dimming effect to make it obvious which are selected. What about onmouseover for the divs and you can use bubbling/capturing (see article) for multiple divs on top of each other.

        Comment

        Working...