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}" />
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

沉默王二

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值