html部分:
<div class="headstyle"><!-- 整个头部div -->
<div onclick="toSmallIndex()" class="head_exchscene">
<div class="topbustype topbustype1">明细</div>
</div>
<div onclick="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变成深色
这篇博客介绍了如何使用HTML、CSS和JavaScript实现点击按钮后颜色变深,再次点击其他按钮时恢复原色的功能。通过示例代码展示了如何定义样式,并使用jQuery处理点击事件来切换选中状态的背景颜色。
7

被折叠的 条评论
为什么被折叠?



