When a page has multiple a tags, and when clicked, it will jump to the current page. How can the clicked tag change color and be highlighted, and other tags return to their original colors?
Use JS to achieve:
Assume the current page is "1.aspx"
1. Set the value of a tag ID:
2. Write JS method:
<script> <br>&(document).ready (function(){ <br>var id = windows.ulr.substring(windows.ulr.IndeOf("?id="),1) //Get the id value<br>var currtA = document.getElementById(id); //Get the currently clicked a tag <br>if(currtA != null) <br>currtA.style.color = "#f00"; <br>}); <br></script>
For other situations, such as clicking the a tag page without jumping, you can write like this:
"" <script> <br>function changeCss(obj){ <br>var alist = document.getElementsByTagName("a"); <br>for(var i =0;i < alist.Length;i ){ <br>alist[i].style. color = "#000"; //Assign primary color to all a tags<br>} <br>obj.style.color = "#f00"; //Highlight the current tag<br>} <br>//Of course You can also use Jquery's $("a").removeCss() and addCss() to achieve <br></script>