find element at an absolute position

后端 未结 2 429
情话喂你
情话喂你 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: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.

提交回复
热议问题