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

85
Views
Update variable when clicking button

I have a slideshow displaying some images. There is a function to make the current image displayed fullscreen when clicking it:

var img = document.querySelectorAll(".main-webcam-img")[slideIndex-1];

img.onclick = function () {
    modal.style.display = "block";
    modalImg.src = img.src;
}

I have prev, next buttons to scroll through the images:

function plusSlides(n) {
    showSlides(slideIndex += n);
}

and a function to see what the current slide is:

function currentSlide(n) {
    showSlides(slideIndex = n);
}

The problem: When clicking the buttons slideIndexchanges (as it should), but var img = document.querySelectorAll(".main-webcam-img")[slideIndex-1]; doesn`t update.

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!