My current code successfully updates part of an src URL for regular images.
let svgz = document.querySelectorAll(".svg");
for (let i = 0; i < svgz.length; i++) {
svgz[i].src = svgz[i].src.replace("light", "dark");
}
Now, I want to achieve the same result with CSS background-image URLs.
I attempted to modify the previous code for background images, but it's not functioning correctly:
let svgbg = document.querySelectorAll(".svgbg");
for (let i = 0; i < svgbg.length; i++) {
svgbg[i].style.backgroundImage = svgbg[i].style.backgroundImage.replace("light", "dark");
}
Any suggestions on how to partially change a background image URL?