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'
});
<script src="jquery.tagsinput.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.tagsinput.css" />
<input name="tags" id="tags" value="foo,bar,baz" />
$('#tags').tagsInput();
GitHub 地址 :https://github.com/xoxco/jQuery-Tags-Input
Gitee 地址 :https://gitee.com/mirrors/jQuery-Tags-Input