Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Image swapper is showing a box instead of my images

i'm having problem where my image swapper isn't showing. I have 4 images :

                <img src="" alt="" class="main-hobby">
                <div>
                    <img class="image1" src="./Assets/slider-1.png" alt="person-learning-new-technology">
                    <img class="image2" src="./Assets/slider-2.png" alt="a-house">
                    <img class="image3" src="./Assets/slider-3.png" alt="person-playing-golf">
                    <img class="image4" src="./Assets/slider-4.png" alt="xbox-controller">
                </div>
            </picture>

so i want the .main-hobby to show each image for 2 seconds.

here is my javascript :

const image2 = document.querySelector('.image2')
const image3 = document.querySelector('.image3')
const image4 = document.querySelector('.image4')
const images = [image1, image2, image3, image4];
let index = 0;

const mainHobby = document.querySelector('.main-hobby');

console.log(images);

window.onload = function () {
    setInterval (change, 2000);
}

function change() {
    index > images.lenght ? index = 0 : index ++;
    mainHobby.src = images[index];
}

but all i see is a black box.

heres the css if needed

     display: block;
     width: 70px;
     height: 70px;
     margin-bottom: 20%;
   }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!