toggle标签切换效果

另外一篇关联文章:(https://www.cnblogs.com/zxyun/p/9316964.html)[https://www.cnblogs.com/zxyun/p/9316964.html]

5.gif

css

.tl-tag{
    width:80px;
    height:30px;
    line-height: 30px;
    background:#E5E5E5;
    border-radius:15px;
    text-align: center;
    margin-left: 20px;
    color: #666666;
}
.tl-tag-active{
    width:80px;
    height:30px;
    line-height: 30px;
    background:#FB633C !important;
    border-radius:15px;
    text-align: center;
    margin-left: 20px;
    color: #FFFFFF !important;
}
.pull_l {
    float: left;
}

html

<div class="clearfix">
    <div class="tl-tag pull_l" onclick="select(this);">短信分类</div>
    <div class="tl-tag tl-tag-active pull_l" onclick="select(this);">高级版</div>
    <div class="tl-tag pull_l" onclick="select(this);">服务类</div>
</div>

js

function select(e, title, price){
   // $(e).addClass("tl-tag-active").siblings("div").removeClass("tl-tag-active");
    $(e).addClass("tl-tag-active").siblings("div").removeClass("tl-tag-active");
    $(e).children(".sel").show(0).parent().siblings().children(".sel").hide(0);
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML标准。 注意:讲述HT...
    kismetajun阅读 27,931评论 1 45
  • 1 Webpack 1.1 概念简介 1.1.1 WebPack是什么 1、一个打包工具 2、一个模块加载工具 3...
    Kevin_Junbaozi阅读 6,842评论 0 16
  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,865评论 1 92
  • 第六天 后来我才明白,这世界上有一种人,第一眼就可以看见对方的灵魂。 美琪是一个特别的人,从她的装束就看得出来,无...
    关馨仁阅读 300评论 0 0
  • 今天下午没有踢球,明天开始清明小假期,回到家让孩子赶紧写了一部分作业,吃过饭等待诗词大会,今天的比拼肯定非...
    周一成长日记阅读 407评论 0 3