做网站|网站建设,就上易助科技网

前端技术文档及相关资料下载

关于前端html、css、js等技术上的各种疑难棘手问题的解决方案探讨及相关资料下载!

JQuery标签输入插件jQuery Tags Input
来源:易助科技网浏览量:2收藏

简介

jQuery Tags Input Plugin 是一个用来实现标签输入的 jQuery 插件。 

您是否使用标签来组织网站上的内容?这个插件会把你无聊的标签列表变成一个神奇的输入,把每个标签变成一个有自己删除链接的风格对象。该插件处理所有数据-您的表单只看到一个逗号分隔的标签列表!

 


(下载的附件中附有DEMO) 

配置项:

$(selector).tagsInput({
'autocomplete_url': url_to_autocomplete_api,
'autocomplete': { option: value, option: value},
'height':'100px',
'width':'300px',
'interactive':true,
'defaultText':'add a tag',
'onAddTag':callback_function,
'onRemoveTag':callback_function,
'onChange' : callback_function,
'delimiter': [',',';'], // Or a string with a single delimiter. Ex: ';'
'removeWithBackspace' : true,
'minChars' : 0,
'maxChars' : 0, // if not provided there is no limit
'placeholderColor' : '#666666'
});


使用

1.  引入文件

<script src="jquery.tagsinput.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.tagsinput.css" />


2.  HTML

<input name="tags" id="tags" value="foo,bar,baz" />


3.  调用

$('#tags').tagsInput();


相关链接

GitHub 地址 :https://github.com/xoxco/jQuery-Tags-Input

Gitee 地址 :https://gitee.com/mirrors/jQuery-Tags-Input