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

114
Views
Chrome extension Javascript button does nothing

I am trying to find a solution to having a slideshow in my chrome extension. I have buttons for > and < within the slideshow and they are not working with the inline JS issue. I have overcome this by putting it all in a JS file but its still not working.

HTML:

<div class="contents">

<div class="description">
    <div id="options-greet" style="font-size: 1.75em; font-weight: bold;"></div>
    <div class="overview_description">
        <div class="slideshow-container">
            <div class="mySlides">
              <q>I love you the more in that I believe you had liked me for my own sake and for nothing else</q>
              <p class="author">- John Keats</p>
            </div>
            <div class="mySlides">
              <q>But man is not made for defeat. A man can be destroyed but not defeated.</q>
              <p class="author">- Ernest Hemingway</p>
            </div>
            <div class="mySlides">
              <q>I have not failed. I've just found 10,000 ways that won't work.</q>
              <p class="author">- Thomas A. Edison</p>
            </div>
            <a class="prev" id="button1" >❮</a>
            <a class="next" id = "button2">❯</a>
            
            </div>

JS file:

    var slideIndex = 1;
    showSlides(slideIndex);
    function plusSlides(n) {
      showSlides(slideIndex += n);
     }
function currentSlide(n) {
  showSlides(slideIndex = n);
}
function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("mySlides");
  var dots = document.getElementsByClassName("dot");
  if (n > slides.length) {slideIndex = 1}    
  if (n < 1) {slideIndex = slides.length}
  for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";  
  }
  for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[slideIndex-1].style.display = "block";  
  dots[slideIndex-1].className += " active";
}

 document.getElementById("button2").addEventListener("onclick", plusSlides(1));
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

When you write 'onclick', plusSlides(1) you're immediately calling plusSlides and assigning the return value to the listener. But you're not returning anything - you're just calling a new function which also doesn't return anything. So, instead, pass a function reference that does call plusSlides when you have a click event.

.addEventListener('onclick', () => plusSlides(1));
about 4 years ago · Juan Pablo Isaza Report
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!