By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,626 Members | 1,750 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,626 IT Pros & Developers. It's quick & easy.

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

P: 2
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!
Nov 23 '08 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 15k+
P: 16,027
If all you want is the divs covered by the semi-transparent box, why not check the positions of the divs on mouse up?
Nov 24 '08 #2

P: 2
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.
Nov 24 '08 #3

Expert Mod 15k+
P: 16,027
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.
Nov 24 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.