Is there a simple way to locate all DOM elements that “cover” (that is, have within its boundaries) a pixel with X/Y coordinate pair?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can have a look at
document.elementFromPointthough I don’t know which browsers support it.Firefox and Chrome do. It is also in the MSDN, but I am not so familiar with this documentation so I don’t know in which IE version it is included.
Update:
To find all elements that are somehow at this position, you could make the assumption that also all elements of the parent are at this position. Of course this does not work with absolute positioned elements.
elementFromPointwill only give you the most front element. To really find the others you would have to set thedisplayof the front most element tononeand then run the function again. But the user would probably notice this. You’d have to try.