How to replace all images with a certain classname?

Viewed 25

So I am attempting to replace all images with another image with a certain classname in order to help with dark/light mode support but I can't seem to figure it out. Here is my code:

function darkenclose() {
const boxes = document.querySelectorAll('.svg');
 boxes.forEach(box => {
   box.src = "images/icon/closewin.svg";
 });
function lightenclose() {
 boxes = document.querySelectorAll('.svg');
 boxes.forEach(box => {
   box.src = "images/icon/closewin2.svg";
 });

Any help would be greatly appreciated.

0 Answers
Related