Changing Backgroundcolor After Hover In Javascript
I need to change hover backgroundColor in Javascript function changeColor(color) { var block = document.getElementsByClassName('kafelek'); for (var i = 0; i < block.length; i++)
Solution 1:
Maybe try the mouseleave
event:
element.addEventListener("mouseleave", function( event ) {
event.target.style.backgroundColor = "purple";
}
Also if you want it to change only when the mouse is on the element, you better use css :hover
, like so:
element:hover {
background-color: #yourcolor;
}
Post a Comment for "Changing Backgroundcolor After Hover In Javascript"