如上图所示,当点击“版面分类”时,改变其颜色,其他标题切换成默认的颜色
代码如下:
css代码:
.titleDefaultColor{
FONT-WEIGHT: bold;
COLOR: #069
}
.titleChangeColor{
FONT-WEIGHT: bold;
color: #FF6600;
}
HTML代码:
<a id="smilies" class="titleDefaultColor" alink="1" οnclick="changeColor(this);" href="#" target="main">${I18n.getMessage("Admin.search")}</a>
给<a>标签自定义一个alink属性,用于在JS中进行查找
js代码:
<script type="text/javascript">
$(document).ready(function() {
});
this.changeColor = function(obj){
$("#nav").find("[alink]").each(function(i){
$(this).removeAttr('class');
$(this).attr('class','titleDefaultColor');
}
);
$(obj).removeAttr('class');
$(obj).attr('class','titleChangeColor');
}
</script>
其中nav为<a> 上级的ID值