Can anyone help me troubleshoot my code? My function load() isn't changing the background of .firstDiv for some reason.
I've checked multiple times but I can't seem to spot any errors.
function load() {
document.getElementsByClassName("firstDiv").style.backgroundImage = "url('https://static.pexels.com/photos/140945/pexels-photo-140945.jpeg')";
}
.firstDiv, .secondDiv {
width: 50%;
height:100vh;
float: left;
}
.firstDiv {
background-image: url("https://static.pexels.com/photos/200303/pexels-photo-200303.jpeg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
box-shadow: inset 0 0 0 1000px rgba(0,0,0,.2);
}
<div class="firstDiv"></div>
<div class="secondDiv">
<button onclick="load()">Change background</button>
</div>