如何自定义jquery自动完成以在DIV中显示 [英] How to customize jquery autocomplete for displaying in a DIV

查看:75
本文介绍了如何自定义jquery自动完成以在DIV中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道,之前我使用过自动完成插件,但jquery网站上的示例看起来非常简单实用:

I'm just wondering, I have used autocomplete plugins before but the example on jquery's website seems very simple and useful:

$(function() {
    var availableTags = [
        "ActionScript",
        "AppleScript",
        "Asp",
        "BASIC",
        "C",
        "C++",
        "Clojure",
        "COBOL",
        "ColdFusion",
        "Erlang",
        "Fortran",
    ];
    $( "#tags" ).autocomplete({
        source: availableTags
    });
});



    <div class="demo">
<div class="ui-widget">
    <label for="tags">Tags: </label>
    <input id="tags">
</div>
</div>

但是,发布的结果都在输入框中。当你点击结果时它们会消失。

However, the results posted are each in input boxes. And when you click away from the results they disappear.

1)我需要结果不会消失,只要输入中的文字与某些值相匹配数组,它需要始终显示它。

1) I need the results to not disappear, as long as there is text in the input that matches some values in the array, it needs to always display it.

2)结果应显示为div。我不需要点击该选项并将其显示在文本框中的功能。我真的只是想做一个动态的即时搜索。

2) The results should appear as divs. I don't need the functionality of clicking on the option and having it appear in the textbox. I'm really just trying to make a dynamic instant search.

问候,
泰勒。

Regards, taylor.

推荐答案

有趣的黑客保持自动完成打开(这不能回答你的问题,但可能会有用):

Funny hack to keep the auto-complete open (this doesn't answer your question but maybe it can be useful in getting there):

http://jsfiddle.net/WUxPd/

$("#tags").autocomplete({
    source: availableTags,
    close: function(event, ui) {
        $('.ui-autocomplete').css('display', 'block')
    }
    });

这篇关于如何自定义jquery自动完成以在DIV中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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