在文本区域内建议/自动完成的 jQuery 插件

发布于 2024-10-05 16:10:36 字数 1539 浏览 11 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

怂人 2024-10-12 16:10:37

如果您引用 jQueryUI(与 jQuery 相同的网站),您可以使用以下内容进行自动完成: http://jqueryui.com /demos/autocomplete/

这也是一个简单的实现:)

希望有帮助!

If you reference jQueryUI (same website as jQuery) you can use the following for auto complete: http://jqueryui.com/demos/autocomplete/

It's a simple implementation as well :)

Hope that helps!

誰認得朕 2024-10-12 16:10:37

这可能看起来像一个黑客,但您可以尝试向用户模仿他正在文本区域中输入,而他实际上是在文本输入中输入,该文本输入位于文本区域中下一个单词的位置。自动完成的建议或点击此覆盖文本输入中的 Enter 或空格,您可以删除文本输入,并将文本输入中的当前单词附加到文本区域。

对于文本输入中的自动完成,您可以使用大量可用于 jquery 的插件中的插件。

This might look like a hack, but you can try imitating to the user that he is typing in the textarea, whereas he would actually be typing in the textinput which is at the position for the next word in a textarea.Once the user selects a suggestion from autocomplete or hits enter or space inside this overlaid textinput, you can remove the text-input with the current word inside the textinput appended to the textarea.

For an autocomplete in text-input you can use on plugin from the plethora of plugins available for jquery.

三生池水覆流年 2024-10-12 16:10:37

您可以尝试 gcomplete 使用 google api 自动完成任何内容,只需稍加修改即可在源代码中,您可以更改标签 input[text] 的行为。

我对插件进行了更改并自动完成最后一个单词,您可以在 github.com/rkmax/gcomplete

我正在研究:
- 自动完成当前单词。
- 确定行数(视觉)和文本区域当前光标位置以显示光标旁边的单词列表,这要归功于 SimpleCoder

you can try gcomplete uses the google api for autocomplete anything, with a little modification to the source code, you can change the behavior about the tag input[text].

i made changes for the plugin and autocomplete the last word, you can test in github.com/rkmax/gcomplete.

I'm working on:
- Autocomplete the current word.
- Determine the number of lines (visual) and Textarea the current cursor position to display the list of words right next to the cursor, thanks to SimpleCoder

挖个坑埋了你 2024-10-12 16:10:36

那么,如果您想从数据库中提取数据,有一个 自动完成插件 可以做到这一点我建议使用 jQuery 中包含的 ajax API

类似这样的东西

$('textarea').keyup(function(){
  $.post('ajax/test.php', function(data) {
   $('#example').autocomplete(data);

   });

});

还要记住,这只是给您一个想法的基本结构。

PS我刚刚发现这个它应该满足您的所有需求。

Well there is the autocomplete plugin that does just that, and if you want to pull data from a database I recomment using the ajax API that is included in jQuery.

something like this

$('textarea').keyup(function(){
  $.post('ajax/test.php', function(data) {
   $('#example').autocomplete(data);

   });

});

Also remember this is just the basic structure to give you an idea.

P.S. I just found this it should fill all your needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文