jQuery autocomplete -默认

<!doctype html>
<html>
<head>
<meta name="content-type" content="text/html; charset=gbk">
<title>jQuery UI Autocomplete - 默认功能</title>
<link rel="stylesheet"
    href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
    $(function() {
        //这里 数据是数组的形式
        var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC",
                "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang",
                "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp",
                "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme","中国","国家" ];
        $("#tags").autocomplete({
            source : availableTags
        });
    });
</script>
</head>
<body>
    <div class="ui-widget">
        <label for="tags">检索: </label> <input id="tags">
    </div>
</body>
</html>

效果图:

  

  

参考:

  http://jqueryui.com/autocomplete/

  http://www.cnblogs.com/lwme/archive/2012/02/12/jquery-ui-autocomplete.html

主要是为了与solr搜索的自动提示功能 结合.

 

posted @ 2015-04-24 15:23  勿妄  阅读(547)  评论(0编辑  收藏  举报