在文本区域中获取插入符号XY坐标 [英] Get caret XY coordinates in text area

查看:122
本文介绍了在文本区域中获取插入符号XY坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何好的JQuery / JS解决方案可以获得文本区域中插入符号的绝对位置(以X / Y坐标或顶部/左侧坐标给出)。

keyDown JQuery函数的本机Event对象给出了光标的x / y坐标,我想要一些与工作插入符相似的东西。



我的目标是添加一个浮动HTML元素,它将相对于工作插入位置定位,所以我需要以某种方式获得它的位置。

Is there any good JQuery/JS solution to get the absolute position of a caret in text area (given in X/Y coordinates OR top/left coordinates).
The native Event object of keyDown JQuery function gives the x/y coordinates of the cursor and I want something similar the works on the working caret.

My goal is to add a floating HTML element the will be positioned relatively to the working caret position so I need to somehow get its position.




我需要解决方案来处理TextArea元素,但任何可编辑html元素的通用解决方案都会更好!



I need the solution to work on TextArea elements but a general solution to any editable html element would be even better!

推荐答案

这个 jQuery插件正是您所需要的!

This jQuery plugin is what you're looking for!

这篇关于在文本区域中获取插入符号XY坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆