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
  • 204,283
  • 31
  • 260
  • 272
Dinesh.r
  • 19
  • 1
  • 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
  • 58,414
  • 16
  • 114
  • 157
Asif
  • 166
  • 9