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變成深色