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

133
Views
Changing the image source when pressing the back button

I have a slider. When clicking next button image is loading.

var t=3
        function next_btn(){
            
            t+=3;
            var imgEl = document.querySelectorAll('.lazy');
            for (let a = 0; a < t; a++) {
                if(imgEl[a].getAttribute('data-original')) {
                imgEl[a].setAttribute('src',imgEl[a].getAttribute('data-original'));
                imgEl[a].removeAttribute('data-original'); 
            }
            }
            

        }


but when clicking previous button image is not loading.

function previous_btn(){
     
            var imgEl = document.querySelectorAll('.lazy');
            
            for (let a =imgEl.length; a >3; a--) {
                if(imgEl[a].getAttribute('data-original')) {
                imgEl[a].setAttribute('src',imgEl[a].getAttribute('data-original'));
                imgEl[a].removeAttribute('data-original'); 
            }
            }
            
           
        }

I tried other things but it didn't work. How can I fix?

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!