Reputation: 13
I have a div with id="container'
that I want to set a -webkit-mask-box-image
for. Currently I have this through css:
#container
{
-webkit-mask-box-image: url('masks/4.png');
width:235px;
height:300px;
}
But I want to set the css through javascript, because the mask should change each hour.
I have tried:
document.getElementById("container").setAttribute("style", "-webkit-mask-box-image: url('masks/"+hour+".png'); width:235px; height:300px;");
But that doesn't work. How do I do it?
Upvotes: 1
Views: 4082
Reputation: 37896
what about
document.getElementById("container").style.setAttribute("-webkit-mask-box-image", "url('masks/"+hour+".png')");
document.getElementById("container").style.setAttribute("width","235px");
document.getElementById("container").style.setAttribute("height","300px");
Upvotes: 0
Reputation: 1266
you can set in JQuery by below Line of Code, Here is DEMO
$('#container').css('-webkit-mask-box-image',"url('masks/4.png')")
Upvotes: 1