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

简介: 版权声明:欢迎转载,请注明沉默王二原创。 https://blog.csdn.net/qing_gee/article/details/80124800 一、效果二、组件下载https://github.com/xoxco/jQuery-Tags-Input三、组件使用下载后的readme中已经对常用的方法参数进行了解释。
版权声明:欢迎转载,请注明沉默王二原创。 https://blog.csdn.net/qing_gee/article/details/80124800

一、效果

图片描述

二、组件下载

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}" />
相关文章
|
5月前
|
JavaScript 算法 数据安全/隐私保护
原生JS实现:密码输入框显示隐藏密码效果
原生JS实现:密码输入框显示隐藏密码效果
128 4
|
11月前
|
前端开发 程序员 Android开发
Bootstrap+jQuery实现卡片标签样式的分页
Bootstrap+jQuery实现卡片标签样式的分页
58 0
|
24天前
|
Web App开发 前端开发 JavaScript
HTML/CSS/JS学习笔记 Day3(HTML--网页标签 下)
HTML/CSS/JS学习笔记 Day3(HTML--网页标签 下)
|
28天前
|
XML JavaScript 前端开发
jQuery获取所有标签
【9月更文挑战第2天】
|
2月前
|
JavaScript 前端开发 API
vue中将验证表单输入框的方法写在一个js文件中(表达式验证邮箱、身份证、号码、两次输入的密码是否一致)
这篇文章介绍了如何在Vue框架中将表单输入验证逻辑封装到一个JavaScript文件中,并通过正则表达式验证邮箱、身份证、手机号等信息,同时确保两次密码输入的一致性。
|
2月前
|
小程序 JavaScript
|
3月前
|
JavaScript
vue + d3.js(v6) 绘制【树状图/思维导图】可折叠/展开,可点击跳转,可带标签
vue + d3.js(v6) 绘制【树状图/思维导图】可折叠/展开,可点击跳转,可带标签
406 1
|
5月前
|
JavaScript 前端开发
JavaScript实现将输入框内容放大的效果
JavaScript实现将输入框内容放大的效果
28 0
|
5月前
|
JavaScript 前端开发
JavaScript实现将输入框中的信息保存到表格中
JavaScript实现将输入框中的信息保存到表格中
24 0