jquery autoComplete 插件
Posted 贝尔塔猫
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery autoComplete 插件相关的知识,希望对你有一定的参考价值。
github:
https://github.com/Pixabay/jQuery-autoComplete/blob/master/demo.html
官网demo
https://goodies.pixabay.com/jquery/auto-complete/demo.html
cdn:
<script src=‘//cdn.bootcss.com/jquery-autocomplete/1.0.7/jquery.auto-complete.min.js‘></script> <link href=‘//cdn.bootcss.com/jquery-autocomplete/1.0.7/jquery.auto-complete.min.css‘ rel=‘stylesheet‘>
我的demo:
参数1:term 为 文本框输入的内容
参数2:suggest 是一个核心函数,将字符串数组添加到自动完成的列表中
$(function() { $(‘#exampleInputAmount‘).autoComplete({ minChars: 1, source: function(term, suggest){ term = term.toLowerCase(); var choices = [‘ActionScript‘, ‘AppleScript‘, ‘Asp‘, ‘Assembly‘, ‘BASIC‘, ‘Batch‘, ‘C‘, ‘C++‘, ‘CSS‘, ‘Clojure‘, ‘COBOL‘, ‘ColdFusion‘, ‘Erlang‘, ‘Fortran‘, ‘Groovy‘, ‘Haskell‘, ‘HTML‘, ‘Java‘, ‘javascript‘, ‘Lisp‘, ‘Perl‘, ‘php‘, ‘PowerShell‘, ‘Python‘, ‘Ruby‘, ‘Scala‘, ‘Scheme‘, ‘SQL‘, ‘TeX‘, ‘XML‘]; var suggestions = []; for (i=0;i<choices.length;i++) if (~choices[i].toLowerCase().indexOf(term)) suggestions.push(choices[i]); suggest(suggestions); } }); })
以上是关于jquery autoComplete 插件的主要内容,如果未能解决你的问题,请参考以下文章