1、html部分

<div class="panel panel-default">
<div class="panel-heading">请选择您需要的分类(可多选)</div>
<div class="list-group" id="category">
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-ok" ></span><p>前端</p></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-ok" ></span><p>后台</p></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-ok" ></span><p>iOS</p></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-ok" ></span><p>java</p></a>
<a href="#" class="list-group-item"><span class="glyphicon glyphicon-ok" ></span><p>测试</p></a>
<a href="#" class="list-group-item" id="newCategory"><span class="glyphicon glyphicon-ok " ></span>
<p>自定义</p>
<div >
<input style="position:relative;width:70%;float:left;" type="text" maxlength="10" placeholder="请输入要添加的类别" class="form-control" name="" >
<button style="float:right;" class="btn btn-primary">添加</button>
</div>
</a>
</div>
<button style="width:30%; float:right;margin-top: 15px;" id="returnNewTask" class="btn btn-success">确定</button>
</div>

2、js

//类别多选栏的样式(小绿勾)
var $category = $("#category");
$category.delegate("a", "click", function (e) {
if ($(this).index() == $("#category a").length - 1) {
$('#newCategory div').css("display", "block");
}
else {
$('#newCategory div').css("display", "none");
$("#newCategory input").val("");
if ($(this).is(".active")) {
$(this).removeClass("active");
}
else {
$(this).addClass("active");
}
;
}
}); $("#newCategory button").on("click", function () {
var item = '<a href="#" class="list-group-item active"><span class="glyphicon glyphicon-ok" ></span><p>' +
$("#newCategory input").val() + '</p></a>';
$("#newCategory").before(item);
$("#newCategory input").val("");
})

3、css

/*******类别多选栏的部分******/
#category .active{
background-color: white;
color: black;
border: 1px solid #E2E2E3;
} #category .badge{
margin-top: -4px;
background-color:transparent;
border: none;
} #category span{
float:right;
display:none;
} #category .active span{
display:block;
float:right;
color: rgb(70, 176, 85);
font-size: 15px;
} #options a{
overflow: hidden;
} #options .panel{
width:100%;
margin-left: auto;
margin-right: auto;
} #newCategory div{
display: none;
}

最新文章

  1. C#冒泡排序算法
  2. OFFSET IN 使用举例
  3. Linux下的删除命令
  4. 解析Path方法备忘
  5. Public, Private and Protect
  6. CentOS 6.5 下载地址
  7. 再eclipse的javaweb项目中添加JQuery文件时jquery-2.1.4.min.js报错
  8. IE9的BUG?jQuery的BUG?
  9. MySQL server version for the right syntax to use near &amp;#39;type=InnoDB&amp;#39; at line 1
  10. poj1094 topsort
  11. 数据可视化-使用EXCEL和PS制作一个复杂饼图
  12. 跟着刚哥梳理java知识点——泛型(十三)
  13. poj3020二分图匹配
  14. 15套java互联网架构师、高并发、集群、负载均衡、高可用、数据库设计、缓存、性能优化、大型分布式 项目实战视频教程
  15. [LeetCode] Redundant Connection 冗余的连接
  16. HttpPost方式调用接口的3种方式
  17. pandas pivot_table或者groupby实现sql 中的count distinct 功能
  18. IE、360浏览器select属性onchange遇到的坑
  19. Makefile ------ := ?= += =的区别
  20. docker基础:dockerfile的介绍

热门文章

  1. apache asp.net
  2. angular中实现jQuery的Document Ready
  3. 练习--python中的Queue与多进程(multiprocessing)
  4. TIPSO--基于JQUERY的消息提示框插件,用起来蛮顺手
  5. 快速搭建Web服务器软件PHP+Apache+MySQL
  6. [转贴]xcode帮助文档
  7. VS2013 取消 直接单击文件 然后直接打开
  8. 【HDOJ】1175 连连看
  9. 汉企C#面向对象——继承Practice
  10. python 零散记录(四) 强调字典中的键值唯一性 字典的一些常用方法