Changing font color on mouseover and click javascript or html - Stack Overflow

I have a couple of html links, that I have onmouseover and onmouseout set to change colors, what I want

I have a couple of html links, that I have onmouseover and onmouseout set to change colors, what I want to be able to do is when I click one of the links, the links is set to a certain color and mouse over effect no longer works on the clicked link but does on the others. these links activate javascript functions but do not direct to another webpage.

Any ideas how I could do this?

<a href="javascript:void(0)" id="paint" onclick="slidedown(this)"  style="color:#FFF" onmouseover="this.style.color = '#FF6600'" onmouseout="this.style.color = '#FFF'"><font style="font-family:pirulen; font-size:12px; margin-left:10px; "><b>Painting</b></font></a>

this is one of my links as you can see I have onmouseover and onmouseout set.

I have a couple of html links, that I have onmouseover and onmouseout set to change colors, what I want to be able to do is when I click one of the links, the links is set to a certain color and mouse over effect no longer works on the clicked link but does on the others. these links activate javascript functions but do not direct to another webpage.

Any ideas how I could do this?

<a href="javascript:void(0)" id="paint" onclick="slidedown(this)"  style="color:#FFF" onmouseover="this.style.color = '#FF6600'" onmouseout="this.style.color = '#FFF'"><font style="font-family:pirulen; font-size:12px; margin-left:10px; "><b>Painting</b></font></a>

this is one of my links as you can see I have onmouseover and onmouseout set.

Share Improve this question asked Jan 18, 2012 at 15:16 user541597user541597 4,36512 gold badges62 silver badges89 bronze badges 1
  • post your current code, so others can make sure any answers will suit your needs – musefan Commented Jan 18, 2012 at 15:17
Add a ment  | 

3 Answers 3

Reset to default 3

Use this CSS to get the hover effect

a{
    color:#fff;
}
a:hover{
    color:#FF6600;
}
a.selected,a.selected:hover{
    color:#000000;
}

Now, on your function slidedown you can add a class .selected when you click on the link.

this.className = this.className + " selected";

You could add a certain styling class to your link when it is clicked which overwrites the other styling and suppresses the mouseover styling.

Apply the hover to a class and make a toogle that changes the link class when clicked, this way the hover will not be applied to the clicked link.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745639118a4637578.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信