表单/表格

jQuery标签输入插件

阿里云


这是一款带自动完成功能的 jQuery 标签输入插件。该 jQuery 标签输入插件还能实现简单的验证功能,并且采用响应式设计,十分实用。

使用方法

在页面中引入 jquery 和 jqueryui 文件,以及 jquery.tagsinput-revisited.css 和 jquery.tagsinput-revisited.js 文件。

也想出现在这里?联系我们
创客主机
  1. <link href="css/jquery-ui.css" rel="stylesheet"> 
  2. <link href="css/jquery.tagsinput-revisited.css" rel="stylesheet"> 
  3. <script type="text/javascript" src="js/jquery.min.js"></script>             
  4. <script type="text/javascript" src="js/jquery-ui.min.js"></script>             
  5. <script type="text/javascript" src="js/jquery.tagsinput-revisited.js"></script>

HTML 代码

使用一个 input 标签作为输入标签的容器,value 中设置的值可以作为预定义标签使用。

  1. <input id="example" name="example" type="text" value="jQuery,Script,Net">

初始化插件

在页面 DOM 元素加载完毕之后,通过下面的方法来初始化该 jquery 标签输入插件。

  1. $('#example').tagsInput();

配置参数

该 jquery 标签输入插件的可用配置参数有:

  1. $('.tagsinput#tags').tagsInput({
  2.   interactive: true,
  3.   placeholder: 'Add a tag',
  4.   minChars: 2,
  5.   maxChars: 20, // if not provided there is no limit
  6.   limit: 5, // if not provided there is no limit
  7.   validationPattern: new RegExp('^[a-zA-Z]+$'), // a pattern you can use to validate the input
  8.   width: '300px', // standard option is 'auto'
  9.   height: '100px', // standard option is 'auto'
  10.   autocomplete: { option: value, option: value},
  11.   hide: true,
  12.   delimiter: [',',';'], // or a string with a single delimiter
  13.   unique: true,
  14.   removeWithBackspace: true,
  15.   onAddTag: callback_function,
  16.   onRemoveTag: callback_function,
  17.   onChange: callback_function
  18. });

Github 地址:https://github.com/underovsky/jquery-tagsinput-revisited

jQuery 标签输入插件

已有 478 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(1)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!