jquery 实现类似百度搜索联想功能

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>jQuery搜索联想</title>
    <script src="script/jquery-1.9.1.js" type="text/javascript"></script>
    <script src="script/jquery-ui.js" type="text/javascript"></script>
    <link href="script/xiala.css" rel="stylesheet" type="text/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"];
            var tagvalue = $("#istags").val().split(',');
            $("#tags").autocomplete({ source: tagvalue });
        });  
    </script>
</head>
<body>
    <input id="istags" runat="server" type="hidden"/>
    <div class="ui-widget">
        <label for="tags">
            Tags:
        </label>
        <input id="tags" /></div>
</body>
</html>

可以在后台给 istags 隐藏于赋值,用逗号隔开,在前台jquery 用split根据逗号分割,联想的只都是后台给赋值的

posted @ 2013-04-09 11:37  日月当空  阅读(6125)  评论(0编辑  收藏  举报