1

When I hover over the button, the div does not change the color of the book div. I can't understand it.

.book {
  height: 100px;
  width: 100px;
  background-color: blue;
}

.button {
  height: 40px;
  width: 100px;
  background-color: black;
  color: white;
}

.button:hover .book {
  background-color: pink;
}
<div class="book">
  BOOK
</div>
<div class="button">
  BUTTON
</div>
j08691
  • 197,815
  • 30
  • 248
  • 265
Dinesh.r
  • 19
  • 5

1 Answers1

1

A solution with Javascript:

function chbg(color) {
  document.getElementById('book').style.backgroundColor = color;
}
<div id="book">Div book</div>
<div id="button" onmouseover="chbg('red')" onmouseout="chbg('white')">Div button</div>
isherwood
  • 52,576
  • 15
  • 105
  • 143
Asif
  • 126
  • 9