码迷,mamicode.com
首页 > Web开发 > 详细

Jquery点击本身,修改出本身之外的其他同级元素的样式

时间:2016-06-20 15:48:59      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

1.引用Jquyer库

2.Jquery代码:

<script type="text/javascript">
    $(function () {
        slidColor(ddaddresstype);
        slidColor(addresstimetype);
    });
    function slidColor(id) {
        $("#"+id).children("a").each(function () {
            $(this).click(function () {
                $(this).addClass("on").siblings().removeClass().addClass("tab");
            });
        });
    }
</script>

3.html代码

.tab {
    border: 1px solid #e5e5e5;
    color: #222222;
    float: left;
    line-height: 26px;
    margin-right: 10px;
    text-align: center;
    width: 100px;
}
.on {
    border: 1px solid #abd13e;
    color: #89b900;
    text-decoration: none;
}
<dd id="ddaddresstype">                            
  <a data-id="1" class="tab" href="javascript:void(0)">家庭地址</a>
  <a data-id="2" class="tab on" href="javascript:void(0)">公司地址</a>
  <a data-id="3" class="tab" href="javascript:void(0)">其他</a>
</dd>

4.实现的效果截图:

技术分享

技术分享

Jquery点击本身,修改出本身之外的其他同级元素的样式

标签:

原文地址:http://www.cnblogs.com/LoveQin/p/5600479.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!