When a page has multiple a tags, the current click a tag will change color, and the other a tags will return the primary colors. The specific implementation is as follows, if you like it, you can refer to the following: when a page has multiple a tags and will jump to the current page after clicking them, how can you highlight the clicked tags with color changes and reply the primary colors to other tags?
Javascript can be used to achieve:
Assume that the current page is "1. aspx"
1. Set a value for tag:
The Code is as follows:
""
""
""
2. JS writing method:
The Code is as follows:
Script
& (Document). ready (function (){
Var id = windows. ulr. substring (windows. ulr. IndeOf ("? Id = "), 1) // obtain the id value
Var currtA = document. getElementById (id); // obtain the currently clicked a tag
If (currtA! = Null)
CurrtA. style. color = "# f00 ";
});
Script
In other cases, if you click the tab page and do not jump to it, you can write as follows:
The Code is as follows:
""
Script
Function changeCss (obj ){
Var alist = document. getElementsByTagName ("");
For (var I = 0; I <alist. Length; I ++ ){
Alist [I]. style. color = "#000"; // assign primary colors to all a labels
}
Obj. style. color = "# f00"; // highlight the current tag
}
// Of course, you can also use Jquery's $ ("a"). removeCss () and addCss () to implement
Script