The Css "hover" selector applies a temporary style to the element, it is not final:
div:hover {
background-color: red;
}
I can do the same with javascript, but it is a bit complicated and impossible for a few elements:
var elem = document.getElementsByTagName ("div")[0];
elem.onmouseover = function () {
this.style.backgroundColor = "red";
}
elem.onmouseout = function () {
this.style.backgroundColor = "transparent";
}
Is there a better way? Something like that:
document.getElementsByTagName ("div")[0].ontemporarymouseover = function () {
this.style.backgroundColor = "red";
}
thank
Caio source
share