Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda