A good program is a favorite program. Good programmers are lazy programmers. Yesterday I studied Jquery's prompt to automatically add search results when imitating Baidu and Google searches, and I felt that the results were okay. I would like to share it with you. Jquery plug-in. See the Code:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
$ (). Ready (function (){
$ (": Text"). result (auto );
Function auto (data ){
$ ("# KeyWord"). val (data. name );
}
$ ("# KeyWord"). autocomplete (obj, {// obj is the data object array Json
MinChars: 0, // indicates the minimum character that is entered before automatic activation is completed.
Max: 5, // indicates the number of entries in the list
AutoFill: true, // indicates Automatic Filling
MustMatch: false, // indicates that the entry must be matched. The content entered in the text box must be the data in the data parameter. If the content does not match, the text box is cleared.
MatchContains: true, // indicates include match, which is equivalent to fuzzy match.
ScrollHeight: 200, // indicates the display height of the list. 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 codeThe Code is as follows:
<Div>
<H4> imitating BaiDu, google Search Prompt <Table>
<Tr> <td> name: <input type = "text" id = "keyWord"/> </td> </tr>
</Table>
</Div>