So im having this problem and not sure how to tackle it
I have <img src="~/images/arrow-repeat.svg">
but i want to change the src to <img src="~/images**/darkmode/**arrow-repeat.svg" depending on the conditions.
I only want to target the path and not the image itself Just the <img src="**~/images/**arrow-repeat.svg" part and i want to add /darkmode/ to the src source without touching the "arrow-repeat.svg"
How can i achive this in javascritp?
I have tried to target the image by adding a ID to it and then doing
document.getElementById('icon').src = "\~/images/";
if (darkSwitch.checked) {
document.getElementById('icon').src = "~/images/darkmode/";
} else {
document.body.classList.remove('darkmode');
}
But it just replaces the whole src, i want to just target the path and not the image