Get cursor or text position in pixels for input element

后端 未结 4 1446
礼貌的吻别
礼貌的吻别 2020-12-01 11:06

IE allows me to create a text range in an input element, upon which I can call getBoundingClientRect() and get the position in pixels of a certain character or

4条回答
  •  無奈伤痛
    2020-12-01 11:28

    2016 update: A more modern HTML5 based solution would be to use the contenteditable property.

    Block of regular text, and text of interest

    We can now find the position of the span using jquery offset(). And of course, the tags can be inserted upfront or dynamically.

提交回复
热议问题