文本,按鈕點擊後顏色變深,點擊其他的恢復原色

html部分:

<div class="headstyle"><!-- 整個頭部div -->
<div οnclick="toSmallIndex()" class="head_exchscene">
<div class="topbustype topbustype1">明細</div>
</div>
<div οnclick="toInventory()" class="head_exchscene">
<div class="topbustype topbustype2">單元信息清單</div>
</div>
<div style="visibility:hidden" class="head_radio">
<span id="Sdata"></span>

</div>

css部分:

        .topbustype{
        background-color : #5c83d8;
        }
        .start{
        background-color : #5578c7;
        }
        .end{
        background-color : #7094e4;

        }

js部分:

        $(function(){
        var collection = $(".topbustype2");
        $.each(collection,function(){
        $(this).addClass("start");
        });
        clickevent(ce);

        });

        //單擊事件
        function clickevent(ce){
        var collection = $(".topbustype");
        $.each(collection,function(){
        $(this).removeClass("end");
        $(this).addClass("start");
        });
        $(cli).removeClass("start");
        $(cli).addClass("end");

        }


        一進入這個界面,topbustype1是默認的深色;點擊topbustype2後,topbustype1恢復原色,topbustype2變成深色

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章