I've an element with a var property set on it like so:
<div class="divwithbackground" style="--page-header-section-background: url('myurlimage.jpg');">
</div>
CSS
.divwithbackground::after {
background-image: var(--page-header-section-background);
background-position: center;
background-size: cover;
}
This actually works well. But what if I have another javascript which sets the property:
document.documentElement.style.setProperty('--page-header-section-background', bgDataValue, 'important');
this way. Well this works if I remove style this from the DIV tag:
style="--page-header-section-background: url('myurlimage.jpg');
But this is not the behavior I want. I would like javascript to replace the already set property. Is this possible ?