1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title>练习</title> 6 <script src="js.js"></script> 7 <script src="jquery-1.9.1.min.js"></script> 8 <script src="jquery.autocomplete.min.js"></script> 9 </head>10 <body>11 <form action="">12 <input type="text" name="country" id="autocomplete"/>13 </form>14 15 </body>16 <script>17 var countries = [18 { value: 'Andorra', data: 'AD' },19 // ...20 { value: 'Zimbabwe', data: 'ZZ' }21 ];22 23 $('#autocomplete').autocomplete({24 lookup: countries,25 onSelect: function (suggestion) {26 alert('You selected: ' + suggestion.value + ', ' + suggestion.data);27 }28 });29 30 </script>31 </html>
插件可以到我的百度网盘下载:http://pan.baidu.com/s/1sj1egCd
效果:
新闻热点
疑难解答