bootstrap-tagsinput的使用简介
来源:互联网 发布:java nio面试题 编辑:程序博客网 时间:2024/06/06 04:18
最近在做标签系统的时候,为了便于用户对标签的操作,如输入或是删除,用到了bootstrap-tagsinput。主要是用到了其中的Typeahead部分。
效果如下:
代码如下:
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title></title> <script src="http://cdn.bootcss.com/jquery/3.1.0/jquery.min.js"></script> <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="http://cdn.bootcss.com/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.min.js"></script> <script src="http://cdn.bootcss.com/typeahead.js/0.11.1/typeahead.bundle.js"></script> <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"> <link href="http://cdn.bootcss.com/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css" rel="stylesheet"> <style type="text/css"> .icon-github { width: 16px; height: 16px; } .bootstrap-tagsinput { width: 100%; } .accordion { margin-bottom:-3px; } .accordion-group { border: none; } .twitter-typeahead .tt-query, .twitter-typeahead .tt-hint { margin-bottom: 0; } .twitter-typeahead .tt-hint { display: none; } .tt-menu { position: absolute; top: 100%; left: 0; z-index: 1000; display: none; float: left; min-width: 160px; padding: 5px 0; margin: 2px 0 0; list-style: none; font-size: 14px; background-color: #ffffff; border: 1px solid #cccccc; border: 1px solid rgba(0, 0, 0, 0.15); border-radius: 4px; -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); background-clip: padding-box; cursor: pointer; } .tt-suggestion { display: block; padding: 3px 20px; clear: both; font-weight: normal; line-height: 1.428571429; color: #333333; white-space: nowrap; } .tt-suggestion:hover, .tt-suggestion:focus { color: #ffffff; text-decoration: none; outline: 0; background-color: #428bca; } </style></head><body><input type="text" /><script>var cities = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), queryTokenizer: Bloodhound.tokenizers.whitespace, prefetch: 'cities.json' //标签所在文件,当然也可以从数据库中读取数据,然后生成json返回});cities.initialize();var elt = $('input');elt.tagsinput({ itemValue: 'id', itemText: 'name', typeaheadjs: { name: 'cities', displayKey: 'name', source: cities.ttAdapter() }});elt.tagsinput('add', { "id": 0 , "name": "Washington"});</script></body></html>
参考:https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples
Bootstrap Tags Input :https://github.com/bootstrap-tagsinput/bootstrap-tagsinput
关于标签的插件还有很多,如
Amaze UI Tags Input :https://github.com/amazeui/tagsinput
0 0
- bootstrap-tagsinput的使用简介
- bootstrap-tagsinput插件展示关键字
- (代码记录)bootstrap tagsinput 基本功能DEMO
- Bootstrap框架----标签Tag输入用法--Bootstrap-tagsinput
- bootstrap使用简介
- BootStrap简介与使用
- jquery.tagsinput.js 实现记录checkbox勾选的顺序
- jQuery TagsInput
- **BOOTSTRAP** Bootstrap简介
- Bootstrap简介
- Bootstrap简介
- bootstrap简介
- Bootstrap简介
- bootstrap简介
- BootStrap简介
- Bootstrap 简介
- Bootstrap 简介
- Bootstrap 简介
- 二维数组拼接字符串递归
- 剑指offer-把数组排成最小的数
- Java字符串
- 1209_最小邮票数
- Bellman-Ford,最短路(在环中,UVA 11090)
- bootstrap-tagsinput的使用简介
- 分布式搜索之搭建Solrcloud(Solr集群)
- Java设计模式简单学习
- Windows下oracle 11g的安装
- 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
- Duilib 模块化
- JDK 1.8 HashMap详细介绍
- 2.11 随记
- android 页面切换左右滑动动画