find element at an absolute position

后端 未结 2 430
情话喂你
情话喂你 2021-01-21 19:38

How would you use jquery to get the element at a particular x, y coordinate? You can .offset and .position to find absolute and relative position using jquery.

相关标签:
2条回答
  • 2021-01-21 20:23

    Like this:

    $(document.elementFromPoint(x, y))
    
    0 讨论(0)
  • 2021-01-21 20:25

    Provided you know the exact coordinates relative to the document:

    function getElsAt(top, left){return $("body").find("*").filter(function(){return $(this).offset().top == top && $(this).offset().left == left})}
    

    The other answer stops at the first overlay.

    0 讨论(0)
提交回复
热议问题