 
						添加引用
最低要求:jquery.autocompleter.css和jquery.autocompleter.min.js。
脚本:
| 1 2 | <scriptsrc="js/jquery.js"type="text/javascript"></script><scriptsrc="js/jquery.autocompleter.min.js"type="text/javascript"></script> | 
样式:
| 1 | <linkrel="stylesheet"href="css/jquery.autocompleter.css"> | 
定义你的autocompleter:
| 1 2 3 | $(function() {    $('input').autocompleter({ source: 'path/to/get_data_request'});}); | 
或用于本地JSON来源:
| 1 2 3 4 5 6 7 8 | vardata = [    { "value": "1", "label": "one"},    { "value": "2", "label": "two"},    { "value": "3", "label": "three"}];$(function() {    $('input').autocompleter({ source: data });}); | 
如果你不会在源对象定义了一个值,标签将被用作后选择在输入字段的默认值。
插件后更改选项的定义:
| 1 | $('#input').autocompleter('option', data); | 
例如:
| 1 2 3 4 | $('#input').autocompleter('option', {    limit: 5,    template: '<img src="{{ image }}" alt="Image for autocompleter list item" /> {{ label }}'}); | 
开放列表:
| 1 | $('#input').autocompleter('open'); | 
关闭页面:
| 1 | $('#input').autocompleter('close'); | 
摧毁插件:
| 1 | $('#input').autocompleter('destroy'); | 
清除所有缓存:
| 1 | $.autocompleter('clearCache'); | 
设置默认值:
| 1 2 3 | $.autocompleter('defaults', {    customClass: 'myClassForAutocompleter'}); | 
例如:
Autocompleter第一名称输入缓存,匹配强调限制和5的结果。
形式:
| 1 2 3 4 5 6 | <labelfor="gender_male">Male</label><inputtype="radio"name="gender"value="male"id="gender_male"checked="checked"/><labelfor="gender_female">Female</label><inputtype="radio"name="gender"value="female"id="gender_female"/><labelfor="firstname">First Name</label><inputtype="text"name="firstname"id="firstname"/> | 
JavaScript:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | $(function() {    $("#firstname").autocompleter({        limit: 5,        cache: true,        combine: function() {            vargender = $("input:radio[name=gender]:checked").val();            return{                gender: gender            };        },        callback: function(value, index) {            console.log( "Value "+value+" are selected (with index "+index+").");        }    });}); | 
主要结构:
| 1 2 3 4 5 6 7 | <divclass="autocompleter"id="autocompleter-1">    <ulclass="autocompleter-list">        <liclass="autocompleter-item">First</li>        ...        <liclass="autocompleter-item">Last</li>    </ul></div> | 
特别申明:
			本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
			本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
			如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com