工具栏图标切换

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        div{
            background-repeat:no-repeat;
            background-size: 100% 100%;
            float:left;
            width:2rem;
            height:2rem;
            margin-right:1rem;
        }
        .one{
            background-image:url("../images/statistic.png");
        }
        .one.active{
            background-image:url("../images/statistic-c.png")
        }
        .two{
            background-image:url("../images/recommend.png")
        }
        .two.active{
            background-image:url("../images/recommend-c.png")
        }
        .three{
            background-image:url("../images/reward.png")
        }
        .three.active{
            background-image:url("../images/reward-c.png")
        }

    </style>
</head>
<body>
<div  class="one active"></div>
<div  class="two"></div>
<div class="three"></div>
</body>
<script type="text/javascript" src="../js/jquery-1.7.2.js"></script>
<script>
    $("div").click(function(){
        $(this).addClass("active");
        $(this).siblings().removeClass("active")
    })
</script>
</html>

  

posted on 2016-01-23 17:40  理智与情感  阅读(190)  评论(0编辑  收藏  举报