跟随光标/插入符而不是鼠标的工具提示
可能的重复:
使用 jQuery 在文本区域中的光标位置创建工具提示
所以我有一个带有巨大文本区域的网站,基本上是整个屏幕。但我想在其中添加单词预测。我有所有的方法来做到这一点,实际上我有,但我需要一个跟随光标的工具提示。有没有办法在 JavaScript 中做到这一点?另外,我所说的光标并不是指鼠标。只要文本区域处于焦点状态,就应该允许用户自由移动鼠标,但工具提示出现在光标所在的位置。这在 JavaScript 中可能吗,还是我在做梦?作为参考,如果有人使用 Adobe Dream Weaver,那么当您键入时,结果将如何显示在单词下方。谢谢!另外,如果您知道有任何 jQuery 插件可以做到这一点,请告诉我们!谢谢!
另外编辑
.....
我之前制作了一个 ToolTip jQuery 插件,但这些总是像这样的鼠标坐标:
function(e) {
if(...){
//Code Here
}
}
您总是导入 'e' 来获取鼠标位置的位置。实际上,我需要的是一种跨浏览器的方式来获取光标在文本区域中的位置。谢谢!
Possible Duplicate:
Create tooltip at cursor position in text area with jQuery
So I have a website with a HUGE text area, basically the whole screen. But I want to add word prediction into this. I have all the ways to make this, actually I have, but I need a ToolTip that follows the cursor. Is there a way to do this in JavaScript? Also, by cursor I don't mean mouse. The user should be allowed to move the mouse freely, as long as the text area is in Focus, but the tool tip appears where the cursor is. Is this possible in JavaScript, or am I dreaming? For reference, if anybody uses Adobe Dream Weaver, than how the results appear under the word as you type. Thanks! Also, if there are any jQuery plugins you know of that may do this, please tell! Thanks!
Edit
Also.....
I have made a ToolTip jQuery plugin before, but those are always mouse coordinates like this:
function(e) {
if(...){
//Code Here
}
}
You have always imported 'e' to get the position of the mouse position. Really, all I need is a Cross Browser way to get the position of the cursor in a TextArea. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题很模糊,我不确定你在要求什么,而且你没有提供示例,所以我没有什么可看的(提示:使用 JSFiddle)
这就是你的吗正在寻找?
这将简单地将工具提示与鼠标对齐。
您可以添加此代码以确保工具提示不会离开视口。
这是一个工作示例: http://jsfiddle.net/MarkKramer/jV2H9/
Your question is very vague, I'm not sure what you're asking for and you didn't provide an example so there's nothing for me to look at (hint: use JSFiddle)
Is this what you're looking for?
That will simple align the tooltip to the mouse.
And you can add this code to make sure the tooltip doesn't leave the viewport.
Here is a working example: http://jsfiddle.net/MarkKramer/jV2H9/