Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  16] [ 3]  / answers: 1 / hits: 49781  / 14 Years ago, fri, october 15, 2010, 12:00:00

Is there a method in jQuery to select an element located at a particular position?



For example, can I select the element that is located at left:100 and top:300 in absolute position?



It would be nice if I could select an element located in a range of positions, for example, select the element that is located left: 100 - 150 px top 200 - 280px.


More From » jquery

 Answers
23

You are looking for the .elementFromPoint() JavaScript/DOM method.



var elem = document.elementFromPoint(100, 100) // x, y


That returns a DOM node, which of course then can be wrapped into a jQuery object:



$(elem).remove(); // for instance


I'm not that aware about the cross-browser compatibility and I would like some guys who know better to edit this post or write a comment about it.



Reference: .elementFromPoint()



Example Link: http://www.jsfiddle.net/YjC6y/22/


[#95310] Wednesday, October 13, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
joanneamiyaa

Total Points: 532
Total Questions: 127
Total Answers: 98

Location: Guam
Member since Tue, Nov 3, 2020
4 Years ago
joanneamiyaa questions
Thu, Apr 30, 20, 00:00, 4 Years ago
Thu, Feb 20, 20, 00:00, 4 Years ago
Mon, Oct 14, 19, 00:00, 5 Years ago
;