0

I am creating a list of DomRects like below where the element is just a paragraph. I am getting DomRects with x any y coordinates which could be text nodes or i tags. I can get the i tags with the x and y coordinates using document.elementFromPoint(x,y) but how would. i get a text node with the x and y coordinates.

    let range = document.createRange();
    range.selectNodeContents(element);
    let elementRectangles = range.getClientRects();
    for (let i = 0; i < elementRectangles.length; i++) {
            let elementRectangle : DOMRect = elementRectangles[i];
//document.elementFromPoint(elementRectangle.x,.elementRectangle.y) this can get i tags, b tags etc
//how do i get text nodes with the coords

    }
Coder1234
  • 389
  • 1
  • 3
  • 9
  • Does this answer your question? [Get DOM text node from point?](https://stackoverflow.com/questions/13597157/get-dom-text-node-from-point) – Titus Jun 05 '23 at 19:20

0 Answers0