I want to change the background image of the container such that when I hover on a link in the div, the background image changes.
Reading in stackoverflow and other sources, this should work, but I have tested in both Chrome and Edge. Neither is working at the moment.
#container {
  width: 50%;
  height: 300px;
  position: relative;
}
#text {
  position: absolute;
  font-size: 3em;
  z-index: 5;
}
#text:hover~#background {
  background-image: url("http://lorempixel.com/400/200/food/");
}
#background {
  width: 100%;
  background-image: url("http://lorempixel.com/400/200/animal/");
  background-position: center;
  background-size: cover;
  height: 100%;
  opacity: 0.5;
  position: absolute;
}<div id="container">
  <div id="background"></div>
  <div id="text"><a href="http://www.google.ca">Google</a></div>
</div> 
     
    