沉默王二

不务正业的IT狗,喜欢读书和写作

jquery.tagsinput.js,不错的标签输入框

一、效果

图片描述

二、组件下载

https://github.com/xoxco/jQuery-Tags-Input

三、组件使用

下载后的readme中已经对常用的方法参数进行了解释。

If additional functionality is required when a tag is added or removed, you may
specify callback functions via the onAddTag and onRemoveTag parameters. Both
functions should accept a single tag as the parameter.

If you do not want to provide a way to add tags, or you would prefer to provide
an alternate interface for adding tags to the box, you may pass an false into
the optional ‘interactive’ parameter. The tags will still be rendered as per
usual, and the addTag and removeTag functions will operate as expected.

If you want a function to be called every time a tag is updated/deleted, set it
as the ‘onChange’ option.

By default, if the cursor is immediately after a tag, hitting backspace will
delete that tag. If you want to override this, set the ‘removeWithBackspace’
option to false.

Options

“`js
$(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’
});


jsp中写法也很简单。

```jsp
<input type="text" class="form-control tags" placeholder="描述商品的关键字" name="keywords" value="${good.keywords}" />
阅读更多
版权声明:本文出自沉默王二的博客,转载必须注明出处。技术交流群 120926808 https://blog.csdn.net/qing_gee/article/details/80124800
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭