I have an element where I set the text color and a different text color for the hover state in CSS. I have javascript, so when I click on an element, it changes the color of the text of the element. It works great, except that it also affects the CSS slope, which I want to leave the same as the previously hover CSS. Is there anyway to either stop css freezing from execution, or set CSS slope?
http://jsfiddle.net/77zg8/
CSS
#test {color: blue;} #test:hover {color:green;}
HTML:
<div id="test" onClick="javascript:change()">qwerty</div>
JavaScript:
function change() {document.getElementById("test").style.color="#cc0000";};
source share