< script type ="text/javascript" src ="jquery.js" ></ script >
<script type= "text/javascript" src= "jquery.autocomplete.js" > </ script >
* This source code was highlighted with Source Code Highlighter .
< input type ="text" name ="q" id ="query" />
* This source code was highlighted with Source Code Highlighter .
$( '#query' ).autocomplete({
serviceUrl: 'service/autocomplete.ashx' , //
minChars: 2, //
delimiter: /(,|;)\s*/, // ,
maxHeight: 400, // ,
width: 300, //
zIndex: 9999, // z-index
deferRequestBy: 0, // (), , , . 300.
params : { country: 'Yes' }, //
onSelect: function (data, value){ }, // Callback , ,
lookup: [ 'January' , 'February' , 'March' ] //
});
* This source code was highlighted with Source Code Highlighter .
{
query: 'Li' , //
suggestions:[ 'Liberia' , 'Libyan Arab Jamahiriya' , 'Liechtenstein' , 'Lithuania' ], //
data:[ 'LR' , 'LY' , 'LI' , 'LT' ] // , . callback
}
* This source code was highlighted with Source Code Highlighter .
var ac = $( '#query' ).autocomplete({ /**/ });
ac.disable();
ac.enable();
ac.setOptons({ zIndex: 1001 });
* This source code was highlighted with Source Code Highlighter .
< div class ="autocomplete-w1" >
< div style ="width:299px;" id ="Autocomplete_1240430421731" class ="autocomplete" >
< div >< strong > Li </ strong > beria </ div >
< div >< strong > Li </ strong > byan Arab Jamahiriya </ div >
< div >< strong > Li </ strong > echtenstein </ div >
< div class ="selected" >< strong > Li </ strong > thuania </ div >
</ div >
</ div >
* This source code was highlighted with Source Code Highlighter .
.autocomplete-w1 { background:url(img/shadow.png) no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; }
.autocomplete { border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE6 specific: */ _height:350px; _margin:0; _overflow-x:hidden; }
.autocomplete .selected { background:#F0F0F0; }
.autocomplete div { padding:2px 5px; white-space:nowrap; overflow:hidden; }
.autocomplete strong { font-weight:normal; color:#3399FF; }
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/74713/
All Articles