Find html element nearest to position (relative or absolute)

后端 未结 5 1820
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 01:52

Given absolute or relative position (top & left) is there any way to get the nearest html element to these co-ordinates?

Or alternately, is there any way to craf

5条回答
  •  佛祖请我去吃肉
    2020-12-10 02:01

    The best way I can think of to do this would be to have a search function loop that loops through all your existing elements and compares the co-ordinates, keeping a copy of the nearest variable all the time.

    Thats the way I can think of doing this, and what I would do if I was under your constraints.

提交回复
热议问题