im trying to set a css custom property with js. The name of the property should be "--path" and the value should be "url(test.png)".
My code looks like this:
window.document.body.style.setProperty("--path", "url(test.png)");
My problem is that now the value of --path is "url(test\.png)". How can i prevent the escaping of this dot?
Add quotes to the path:
window.document.body.style.setProperty("--path", "url('test.png')");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With