184
rated 0 times
[
189]
[
5]
/ answers: 1 / hits: 126795
/ 13 Years ago, tue, november 29, 2011, 12:00:00
I have a div with an id of button. I am trying to change its background to become blue when I hover (without using the CSS hover selector).
var item = document.getElementById(button);
item.addEventListener(mouseover, func, false);
function func()
{
var item = document.getElementById(button);
item.setAttribute(style, background-color:blue;)
}
This, however, only sets the color of the item to blue when I hover, but does not reset it to white after I move mouse away. How can I correct this? (btw, mouseenter and mouseleave do not work with this seemingly).
More From » dom