When a page has more than a label, and click will jump to the current page, how to achieve the click of the label color highlighting, other tags back to the primary colors?
Use JS to achieve:
Suppose the current page is "1.aspx"
1. Set the value for a label ID:
Copy Code code as follows:
<a href= "1.aspx?id=1" id= "1" target= "_parent" > "</a>
<a href= "1.aspx?id=2" id= "2" target= "_parent" > "</a>
<a href= "1.aspx?id=3" id= "3" target= "_parent" > "</a>
2. Write JS method:
Copy Code code as follows:
<script>
& (document). Ready (function () {
var id = windows.ulr.substring (windows.ulr.IndeOf ("? id="), 1)//Get ID value
var Currta = document.getElementById (ID); Get the currently clicked a tag
if (Currta!= null)
CurrtA.style.color = "#f00";
});
</script>
For other cases, such as clicking on a label page does not jump, you can write this:
Copy Code code as follows:
<a href= "#" onclick= "Changecss (This)" > "</a>
<script>
function Changecss (obj) {
var alist = document.getElementsByTagName ("a");
for (var i =0;i < alist. length;i++) {
Alist[i].style.color = "#000"; Assign primary colors to all a labels
}
Obj.style.color = "#f00"; Make the current label highlight
}
Of course, you can also use jquery's $ ("a"). Removecss () and ADDCSS () to implement
</script>