Reputation: 11
I have a problem and don't know the solution. Here is my HTML
<div id="thumb">
</div>
CSS:
#thumb {
width: 100%;
position: relative;
height: 557px;
background-image: linear-gradient(
rgba(252, 191, 73, 0.3),
rgba(252, 191, 73, 0.3)
),
url("../img/thumb.jpg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
text-align: center;
color: #000;
}
JS:
var sliderGet = document.getElementById("thumb").style.backgroundImage;
sliderGet = 'url("../img/thumb2.jpg")';
There is no way to change to thumb2.jpg using js...
Upvotes: 0
Views: 45
Reputation: 996
You need to change it directly.
document.getElementById("thumb").style.backgroundImage = 'url("../img/thumb2.jpg")'
Upvotes: 0
Reputation: 322
You can try this
document.getElementById("thumb").style.backgroundImage = 'url("../img/thumb2.jpg")'
Upvotes: 1