admin管理员组文章数量:1435509
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
3 Answers
Reset to default 3Use 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.
本文标签: Changing font color on mouseover and click javascript or htmlStack Overflow
版权声明:本文标题:Changing font color on mouseover and click javascript or html - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745639117a2667743.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论