Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the last-clicked anchor to be a different color from all other links?

a:link {color:#FF0000} /* unvisited link */
a:visited {color:#00FF00} /* visited link */
a:hover {color:#FF00FF} /* mouse over link */
a:active {color:#0000FF} /* selected link */

The pseudo-classes (link, visited, hover, active) don't do exactly what I want which is to highlight the last-clicked link on a page to be a different color from all of the other links on the page.

Would this require JQuery and, if so, any suggestions?

like image 910
blueberry pancake Avatar asked Jul 19 '09 23:07

blueberry pancake


People also ask

How do I change the color of a link after clicking?

To change the color of hyperlink text, click Hyperlink, and then click More Colors. To change the color of the followed hyperlink text, click Followed Hyperlink, and then click More Colors.

How do you change the link color when clicked in HTML?

To change the color of links in HTML, use the CSS property color. Use it with the style attribute. The style attribute specifies an inline style for an element. Use the style attribute with the CSS property color to change the link color.

How do I change the color of a clicked link in CSS?

To change the link color, we have to use the color property of CSS. The name of the color can be given in any valid format, such as the color name, rgb() value, or HEX value.

What specifies the color of a link when it is clicked?

By default, a link will appear like this (in all browsers): An unvisited link is underlined and blue. A visited link is underlined and purple. An active link is underlined and red.


1 Answers

It wouldn't require jQuery, but it's sure easy to do with jQuery.

$("a").click(function () { 
      $("a").css("color", "blue");
      $(this).css("color", "yellow");
    });
like image 199
womp Avatar answered Sep 28 '22 13:09

womp