<body class="light">
<div class="switch">
    <input type="checkbox" id="checkbox" class="checkbox hoverable">
    <img id="img" src="https://dummyimage.com/600x400/0f3/fff">
</div>  
</body>
.light {
  background-color: #ececec;
}
.dark {
  background-color: #000;
}

/*Стили для переключателя*/
.switch {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
}

.switch input[type="checkbox"] {
  position: relative;
  width: 70px;
  height: 35px;
  -webkit-appearance: none;
  outline: none;
  background-color: #fff;
  border-radius: 20px;
  -webkit-transition: .5s;
  transition: .5s;
  -webkit-box-shadow: 2px 0 14px rgba(0, 0, 0, 0.2);
          box-shadow: 2px 0 14px rgba(0, 0, 0, 0.2);
}

.switch input[type="checkbox"]:checked {
  background-color: #101012;
}

.switch input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 35px;
  height: 35px;
  border-radius: 20px;
  top: 0;
  left: 2px;
  background-color: #101012;
  -webkit-transition: .5s;
  transition: .5s;
  -webkit-transform: scale(0.8);
          transform: scale(0.8);
}

.switch input:checked[type="checkbox"]:before {
  left: 35px;
  background-color: #fff;
}
$(document).ready(function(swapImages){
    $(".checkbox").click(function(){
        $(".light").toggleClass("dark");
        swapImages();
    });
});

const images = [
    {
      selector: '#img',
      dark: 'https://dummyimage.com/600x400/fc0/fff',
      light: 'https://dummyimage.com/600x400/0f3/fff'
    },
    function swapImages() {
        const isDark = $('.light').hasClass('dark');
        for (let image of images) {
          $(image.selector).attr('src', isDark ? image.dark : image.light);
        }
    }
];

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://code.jquery.com/jquery-3.4.1.min.js