我有三项:将军、秘书和司库。我想这样当我将鼠标悬停在链接上时,文本下方会出现一个边框。但我也想让它在我点击它之后,边框仍然存在。点击后,如果我将鼠标悬停在另一个链接上,边框也应该出现(例如,我点击一般,那么红色边框应该保留;如果我然后将鼠标悬停在秘书上,红色边框会保留,但会出现绿色边框;如果我然后点击秘书,红色边框消失,绿色边框保留)
这是我的js:
$(document).ready(function(){
var height = $(".content_box").height() - 50;
$(".general_box").css("height","0");
$(".general_box").css("border-bottom","4px solid white");
$("#general_heading a")
.hover(function(){
$(this).css("border-bottom","4px solid rgb(230,0,0)");
$("#secretary_heading a").css("border-bottom","4px solid white");
$("#treasurer_heading a").css("border-bottom","4px solid white");
},function(){
$(this).css("border-bottom","4px solid white");
})
.click(function(){
$(this).css("border-bottom","4px solid rgb(230,0,0)");
$("#secretary_heading a").css("border-bottom","4px solid white");
$("#treasurer_heading a").css("border-bottom","4px solid white");
$("#secretary_box").stop(true).css("height","0");
$("#treasurer_box").stop(true).css("height","0");
$("#general_box").animate({height:height},2000,"easeOutBounce");
$("#general_box ul").fadeIn(2000);
$("#secretary_box ul").css("display","none");
$("#treasurer_box ul").css("display","none");
});
$("#secretary_heading a")
.hover(function(){
$(this).css("border-bottom","4px solid rgb(0,180,0)");
$("#treasurer_heading a").css("border-bottom","4px solid white");
$("#general_heading a").css("border-bottom","4px solid white");
},function(){
$(this).css("border-bottom","4px solid white");
})
.click(function(){
$(this).css("border-bottom","4px solid rgb(0,180,0)");
$("#treasurer_heading a").css("border-bottom","4px solid white");
$("#general_heading a").css("border-bottom","4px solid white");
$("#general_box").stop(true).css("height","0");
$("#treasurer_box").stop(true).css("height","0");
$("#secretary_box").animate({height:height},2000,"easeOutBounce");
$("#secretary_box ul").fadeIn(2000);
$("#general_box ul").css("display","none");
$("#treasurer_box ul").css("display","none");
});
$("#treasurer_heading a")
.hover(function(){
$(this).css("border-bottom","4px solid rgb(0,0,200)");
$("#secretary_heading a").css("border-bottom","4px solid white");
$("#general_heading a").css("border-bottom","4px solid white");
},function(){
$(this).css("border-bottom","4px solid white");
})
.click(function(){
$(this).css("border-bottom","4px solid rgb(0,0,200)");
$("#secretary_heading a").css("border-bottom","4px solid white");
$("#general_heading a").css("border-bottom","4px solid white");
$("#general_box").stop(true).css("height","0");
$("#secretary_box").stop(true).css("height","0");
$("#treasurer_box").animate({height:height},2000,"easeOutBounce");
$("#treasurer_box ul").fadeIn(2000);
$("#secretary_box ul").css("display","none");
$("#general_box ul").css("display","none");
});
});