是否可以在'< textarea>`中将鼠标指针放在鼠标光标下方? [英] Is it possible to get the word under the mouse cursor in a `<textarea>`?

查看:132
本文介绍了是否可以在'< textarea>`中将鼠标指针放在鼠标光标下方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在< textarea>



I在< p> 标签或类似的html输出标签中,例如 here ,但基于< span> 的解决方案doesn 'code>< textarea> ,原因很明显。



我考虑的一种方法是点火一个jQuery click()事件放置光标,然后使用类似Tim Down的回答获取开始和结束点的选择在文本区域/ 3053640#3053640>这里得到基于光标位置的当前单词。但是一个 click()事件似乎并没有将光标放在所有位置。



所以答案是也是足够的。如何在< textarea> 中模拟点击事件,以便将光标置于当前鼠标位置?

解决方案

您可以查看 HTML5 CONTENT EDITABLE ,这样做帮助您合并您在问题中给出的第一个链接并获得解决方案

Is it possible to get the word under the mouse cursor in a <textarea>?

I have seen this question asked many times regarding text in <p> tags or similar html output tags, such as here, but the <span> based solution doesn't work with a <textarea>, for obvious reasons.

One approach I have considered is to fire a jQuery click() event to place the cursor and then use something like Tim Down's answere here to get the current word based on the cursor location. But a click() event doesn't seem to place the cursor at all.

So that answer would be sufficient as well. How do I mimic a click event within a <textarea> so as to place the cursor at the current mouse position?

解决方案

You could have a look at HTML5 CONTENT EDITABLE, this would help you to merge the first link you gave in your question and get your solution

这篇关于是否可以在'&lt; textarea&gt;`中将鼠标指针放在鼠标光标下方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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