Css Change Body Background-color On Button Hover?
For my Website, I have a set background-color of the body, for example body { background-color: #FFFFFF; } I also have a button defined in the .html-File (Let's say it has the ID
Solution 1:
It's not possbile in CSS. In JavaScript it's quite easy, you're looking for onmouseover/out
events.
var button = document.getElementById('hover');
var body = document.body;
button.onmouseover = function() {
body.className = 'hovered';
}
button.onmouseout = function() {
body.className = '';
}
body {background: #000;}
body.hovered {background: #ff0;}
<buttonid="hover">button</button>
Post a Comment for "Css Change Body Background-color On Button Hover?"