1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>练习</title> <script src="js.js"></script> <script src="jquery-1.9.1.min.js"></script> <script src="jquery.autocomplete.min.js"></script> </head> <body> <form action=""> <input type="text" name="country" id="autocomplete"/> </form>
</body> <script> var countries = [ { value: 'Andorra', data: 'AD' },
{ value: 'Zimbabwe', data: 'ZZ' } ];
$('#autocomplete').autocomplete({ lookup: countries, onSelect: function (suggestion) { alert('You selected: ' + suggestion.value + ', ' + suggestion.data); } });
</script> </html>
|