Hi,
Is there a way to get the bounding rect of a text node?
The getBoundingClientRect() method is defined on elements only, and the parent element is bigger then the actual text node.
10x!
views:
242answers:
2
A:
This has already been sort-of answered here: http://stackoverflow.com/questions/396649/retrieving-dom-textnode-position
Reinis I.
2009-09-22 16:21:32
A:
Wrap the text node in a <span>
, get the boundingRect
of that span.
var span = document.createElement('span');
textNode.parentNode.insertBefore(span, textNode);
span.appendChild(textNode);
var rect = span.getBoundingClientRect();
eyelidlessness
2009-09-22 16:29:30