使用CSS更改选定的链接颜色? [英] Change selected link color using CSS?
本文介绍了使用CSS更改选定的链接颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为一组对象定义了一个类(item1).
I've defined a class (item1) for a set of objects.
是否可以将我单击/选择的对象(来自该类)的红色文本置于颜色中,并将所有其他对象(来自该类)的颜色置于黑色文本中?
Is it possible to put red text color the object (from the class) that I click/select and put all the other objects (from the class) in black text color?
这是我应用课程(item1)的代码:
Here's is the code where I apply the class (item1):
<td>
<a class="item1" href="/menu2" onclick="">
Menu1
</a>
</td>
<td>
<a class="item1" href="/menu2" onclick="">
Menu2
</a>
</td>
如何在CSS文件中执行此操作?
How can I do this in the css file?
推荐答案
这是小提琴!
这是代码:
HTML
<td>
<a class="item1" href="#">
Menu1
</a>
</td>
<td>
<a class="item1" href="#">
Menu2
</a>
</td>
JS
$('.item1').click(function(e){
$('.item1').css("color", "black");
$(this).css("color", "red");
});
这篇关于使用CSS更改选定的链接颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文