如何将最后点击的锚点设置为与所有其他链接不同的颜色? [英] How to set the last-clicked anchor to be a different color from all other links?

查看:25
本文介绍了如何将最后点击的锚点设置为与所有其他链接不同的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

这是否需要 JQuery,如果需要,有什么建议吗?

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

推荐答案

它不会需要 jQuery,但使用 jQuery 肯定很容易.

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");
    });

这篇关于如何将最后点击的锚点设置为与所有其他链接不同的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆