A good procedure is a program that a lazy person likes. A good programmer is a lazy programmer. Yesterday studied jquery imitate Baidu, Google search automatically supplemented search results prompts, feel the effect is OK. To share with you. The required jquery plugin. Please look at the code:
Copy Code code as follows:
<script type= "Text/javascript" >
$ (). Ready (function () {
$ (": Text"). result (auto);
function Auto (data) {
$ ("#keyWord"). Val (Data.name);
}
$ ("#keyWord"). AutoComplete (obj, {//obj is a data object array JSON
minchars:0,//represents the smallest character that is filled in before automatic activation is completed
Max:5,//representing the number of entries in the list
Autofill:true,//indicates automatic padding
Mustmatch:false,//means must match the entry, the text box input, must be the data parameter, if does not match, the text box is emptied
Matchcontains:true,//representation contains matches, equivalent to fuzzy matching
SCROLLHEIGHT:200,//Indicates the height of the list display, the default height is 180
Formatitem:function (Row) {
return row.name;
},
Formatmatch:function (Row) {
return row.name;
},
Formatresult:function (Row) {
return row.value;
}
});
});
</script>
Jsp:
Copy Code code as follows:
<div>
<table >
<tr><td> Name: <input type= "text" id= "KeyWord"/></td></tr>
</table>
</div>