点击其他a标签原a标签恢复

假设有3个a标签,当点击第一个标签时,标签是一种颜色,不点击时,保持点击后的颜色,但点击其他a标签,该标签恢复颜色。

css:

a{ text-decoration:none;font-size:12px;color:blue}
a:hover{color:red}
a:FOCUS{  /* 设置鼠标移动后焦距 */
color: #b34927;
}

js:

//a标签点击是个颜色,不点击是另一个颜色。
$("document").ready(function(){
    /* $("a").click(function(){
        $(this).css("color", "white");
         $(this).siblings().css("color","");
    }); */
    
    //
     var aList = document.getElementsByTagName("a");
     for (var i = 0, len = aList.length; i < len; i++) {
     aList[i].removeAttribute("style");
     }
     this.style.color = "red"; //所要设置的颜色


});
原文地址:https://www.cnblogs.com/ciscolee/p/11273173.html