Как поменять изображение по нажатию на переключатель? Надо поменять белый на черный

введите сюда описание изображения введите сюда описание изображения

body{
    background: #222222;
}
.electrick-scooter {
    width: 100%;
    height: 100%;
}

.electrick-scooter__container {
    display: flex;
    flex-direction: column;
    min-height: 885px;
    padding-top: 220px;
    background-image: url(../img/electrick-scooter/electick-scooter-white.png);
    background-repeat: no-repeat;
    background-position-x: 164px;
   
}

.electrick-scooter__content {
    margin-bottom: 62px;
}

.electrick-scooter___title {
    font-family: 'Gilroy-Semibold';
    font-size: 80px;
    line-height: 100%;
    color: #F1F1F1;
    margin-bottom: 28px;
}

.electrick-scooter__text {
    width:481px ;
    font-family: 'Gilroy-Semibold';
    font-size: 30px;
    line-height: 120%;
    color: #FF4C0D;
}

.btn {
    position: relative;
    height: 54px;
    width: 256px;
  }
  .btn input {
    position: relative;
    width: 248px;
    height: 54px;
    outline: none;
    cursor: pointer;
    appearance: none;
    
  }

  .btn input:before,
  .btn input:after {
    z-index: 2;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Gilroy-Bold';
    font-size: 16px;
    line-height: 150%;
  }

  .btn input:before {
    content: "Белый";
    left: 32px;
  }

  .btn input:after {
    content: "Черный";
    right: 33px;
  }

  .btn label {
    z-index: 1;
    position: absolute;
    width:118px;
    top: 2px;
    bottom: 2px;
    border-radius: 65px;
  }

  .btn.btn-1 input {
    transition: 0.3S ease-in-out;
  }

  .btn.btn-1 input:not(:checked) {
    border: 3px solid #F1F1F1;
    border-radius: 108px;
  }

  .btn.btn-1 input:not(:checked):before {
    color: #151515;
  }

  .btn.btn-1 input:not(:checked):after {
    color: #F1F1F1;
    transition: 0.3s ease-in-out;
  }

  .btn.btn-1 input:not(:checked):after {
    color: #F1F1F1;
    transition: 0.3s ease-in-out;
  }

  .btn.btn-1 input:not(:checked) + label {
    left: 1px;
    background: #F1F1F1;
    transition: 0.3s ease-in-out;
  }

  .btn.btn-1 input:checked {
    border: 3px solid #F1F1F1;
    transition: 0.3s ease-in-out;
    border-radius: 118px;
  }

  .btn.btn-1 input:checked:before {
    color: #F1F1F1;
  }

  .btn.btn-1 input:checked:after {
    color: #151515;
  }

  .btn.btn-1 input:checked + label {
    left: 128px;
    background: #F1F1F1;
    transition: 0.3s ease-in-out;
  }
<main class="main">
            <section  class="electrick-scooter">
                <div id="scooter" class="electrick-scooter__container">
                    <div class="electrick-scooter__content">
                        <h1 class="electrick-scooter___title">
                            Стильный электросамокат <br> с мощным аккумулятором
                        </h1>
                        <p class="electrick-scooter__text">
                            Улучшенная производительность для дальних путешествий.<br>Работает так же просто, <br>как и выглядит.
                        </p>
                    </div>
                    <span  class="btn btn-1">
                        <input type="checkbox" name="" id="switch" />
                        <label for="switch"></label>
                    </span>
                </div>
            </section>
        </main>

Пробовала и через переключатель и через js, у меня не получается из-за недостатка знаний. Помогите пожалуйста. Может надо что-то переделать или изображение вынести из backgroundа. изображения которые надо поменять [1]: https://i.stack.imgur.com/uFSrQ.png


Ответы (1 шт):

Автор решения: Alice S

Простой способ:

<script>
        document.getElementById("switch").addEventListener("change", () => {
        let checkbox = document.getElementById("switch");
        let container = document.getElementById("scooter");
        if (checkbox.checked) {
        container.style.background = "url(https://i.stack.imgur.com/iw4hD.png) no-repeat 164px";
        } else container.style.background = "url(https://i.stack.imgur.com/PgM1W.png) no-repeat 164px";
        
        })
        </script>
→ Ссылка