DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> Jquery模仿Baidu、Google搜索時自動補充搜索結果提示
Jquery模仿Baidu、Google搜索時自動補充搜索結果提示
編輯:JQuery特效代碼     
好程序就是懶人喜歡的程序。好程序員就是懶人程序員。昨天研究了一下Jquery 模仿Baidu、Google搜索時自動補充搜索結果的提示,感覺效果還行。特意和大家分享一下。所需Jquery插件。請看代碼:
. 代碼如下:
<script type="text/javascript">
$().ready( function () {

$(":text").result(auto);

function auto(data){
$("#keyWord").val(data.name);
}

$("#keyWord").autocomplete(obj, {//obj是數據對象數組Json
minChars: 0, //表示在自動完成激活之前填入的最小字符
max: 5, //表示列表裡的條目數
autoFill: true, //表示自動填充
mustMatch: false, //表示必須匹配條目,文本框裡輸入的內容,必須是data參數裡的數據,如果不匹配,文本框就被清空
matchContains: true, //表示包含匹配,相當於模糊匹配
scrollHeight: 200, //表示列表顯示高度,默認高度為180

formatItem: function (row) {
return row.name;
},
formatMatch: function (row) {
return row.name;
},
formatResult: function (row) {
return row.value;
}
});
});
</script>

jsp:
. 代碼如下:
<div>
<h4> 模仿BaiDu,google搜索提示功能</h4>
<table>
<tr><td>名稱:<input type="text" id="keyWord" /></td></tr>
</table>
</div>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved