天天看点

jquery autocomplete demo

鏍规嵁鐢ㄦ埛杈撳叆鍊艰繘琛屾悳绱㈠拰杩囨护锛岃鐢ㄦ埛蹇€熸壘鍒板苟浠庨璁惧€煎垪琛ㄤ腑閫夋嫨銆?/h2>
  • jquery.autocomplete鍙傝€冨湴鍧€

    http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

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

  • jquery.autocomplete婧愮爜
<html>
<head>
    <title>jquery autocomplete demo</title>
    <meta http-equiv="content-type" content="text/html; charset=gbk" />
    <script src="<%=path%>/auto/jquery-1.7.1.min.js"></script>
    <script src="<%=path%>/auto/jquery.autocomplete.js"></script>
    <link rel="stylesheet" href="<%=path%>/auto/jquery.autocomplete.css" />
    <script type='text/javascript'>
            //鍙敼鎴恆jax鍙樻垚鍔ㄦ€佹暟鎹?            var address = [
            { name: "瑗垮畨", to: "xian" },
            { name: "鍖椾含", to: "beijing" },
            { name: "瑗垮畞", to: "xining" },
            { name: "瑗胯棌", to: "xizang" },
            { name: "澶╂触", to: "tianjin" },
            ]; 
            $(function(){
                $('#keyword').autocomplete(address, {
                    max: , //鍒楄〃閲岀殑鏉$洰鏁?                    minChars: , //鑷姩瀹屾垚婵€娲讳箣鍓嶅~鍏ョ殑鏈€灏忓瓧绗?                    width: , //鎻愮ず鐨勫搴︼紝婧㈠嚭闅愯棌
                    scrollHeight: , //鎻愮ず鐨勯珮搴︼紝婧㈠嚭鏄剧ず婊氬姩鏉?                    matchContains: true, //鍖呭惈鍖归厤锛屽氨鏄痙ata鍙傛暟閲岀殑鏁版嵁锛屾槸鍚﹀彧瑕佸寘鍚枃鏈閲岀殑鏁版嵁灏辨樉绀?                    autoFill: false, //鑷姩濉厖
                    formatItem: function(row, i, max) {
                        return row.name;
                    },formatMatch: function(row, i, max) {
                        return row.name + row.to;
                    },formatResult: function(row) {
                        return row.to;
                    }
                });
            });
        </script>
</head>
<body>
        <h1>jquery autocomplete demo</h1>
        <h1>
            <input type="text" id="keyword"  style="width: 200px;"/>
        </h1>
    </body>
</html>