使用jquery自动完成和工具提示

如何显示这样的自动完成和工具提示? 在此处输入图像描述

谢谢大家。

只是

http://docs.jquery.com/Plugins/autocomplete

有一些CSSfunction。 您可以使用Chrome > Inspector查看他们添加哪种样式来创建此类UI l&f

编辑

基本上它是在jquery中hover绑定

$("li").hover(fn);

在这个例子中(wowhead.com),他们调用一个链接,它是autocomplete div的一部分

  

和jquery做一个.ajax()调用url像这样: https://stackoverflow.com/item=19003&power

返回的数据在json中

 $WowheadPower.registerItem('18422', 0, { name_enus: 'Head of Onyxia', quality: 4, icon: 'INV_Misc_Head_Dragon_01', tooltip_enus: '
Head of Onyxia
Binds when picked up
Unique
This Item Begins a Quest
Requires Level 60
Item Level 60
"The head of the Black Dragonflight\'s Brood Mother"
' });

它们以div显示,相对于鼠标指针位置定位

我没有提取确切的代码,但有可能,他们的.js文件只是压缩,而不是混淆

您可以使用“title”属性:

  $(function() { //field desc -> is the "tooltip" var availableTags = [ { label: "Choice1", value: "value1", desc: "descricao 1" }, { label: "Choice2", value: "value2", desc: "descricao 2 bla bla bla" }, { label: "Choice3", value: "value3", desc: "descricao 3 ble" }, { label: "Choice4", value: "value4", desc: "descricao 4 bli bli bli" } ]; $( "#tags" ).autocomplete({ source: availableTags, focus: function( event, ui ) { $(".ui-autocomplete > li").attr("title", ui.item.desc); } }); }); 

https://jsfiddle.net/m02suadf/

您可以使用jquery-ui中的“tooltip”(在1.9版中添加)在Internet上找到其他示例。