I can use document.createRange()
to get a range of individual characters in a textnode, then Range.getBoundingClientRect()
to get the position on the screen of those characters. I want to do the same thing for text in an input
element, which used to be possible in IE only with createTextRange
.
This jsfiddle sums up the problem - http://jsfiddle.net/sobu5ug2/2/
I can't use the same method for an input
because Range.setStart/End
only works on the element level, not the character level, for an input
. I also tried window.getSelection().getRangeAt(0).getBoundingClientRect()
but that returns a bounding rect of all 0's. I'd like to do this without actually selecting the text, if possible.
Is there any way to do this in a modern browser? Thanks.