views:

194

answers:

2
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?

+4  A: 

You definitely can't do it with css.

With jQuery you could do something like

$("a").live("click", function() {
    $("a").removeClass("yourHighlightClass");
    $(this).addClass("yourHighlightClass");
});
Adam A
Why do you use a.bind instead of a.click? I'm not familiar with bind.
blueberry pancake
blueberry pancake, click(callback) is a shortcut to bind('click', callback)
eyelidlessness
Adam A, wouldn't .live() be a better fit?
eyelidlessness
touche. will edit.
Adam A
+4  A: 

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");
    });
womp
Wow. That's nice. Can't believe how little code it takes. Thanks.
blueberry pancake
jQuery rocks the kasbah.
womp
Would love a comment on the downvote.
womp
You don't use classes, plus you duped my answer 4 minutes later. I didn't think it added anything. No offense meant.
Adam A
It is certainly *not* a dupe, and I resent the accusation. I hope you don't downvote answers in all the threads that you yourself personally answer.
womp