Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda