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

212
Visualizações
Divs that dissapear on click — how to make a loop so when the last div dissapears the first one comes back?

currently working on a project where I have lots of text I decided to put each paragraph onto a panel (DIV), they are all on top of each other, when you click on a the div it disappears (in the CSS the panel moves to -100% of screen) and then we can see the next div etc. and this goes on and on. but my problem is when I arrive at the last div I have a blank page after and have no way of going back except for refreshing the page which is not very ideal. So I was wondering if there was a system to make a loop that makes me go through all the divs (data-target=".panel-1",-2,-3-,4 etc.) and at the last one brings me back to the first div, so it makes a proper rotation.

In the example below I only put two panels, but there are much more. What would be the simplest way to do this? Thanks a lot!

JQuery


$(document).ready(function () {
    grade();
});


function grade() {
    $(".grade").on("click", function () {
        var target = $(this).attr('data-target');
        // console.log(1);
        $(target).addClass('off');
    });
}
.panel {
    position: fixed;
    top: 0;
    left: 0px;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    transition: left 0.8s ease-in-out;
}

.panel.off {
    left: -100%;
}

.panel-content {
    height: 100%;
    overflow: auto;
}

.panel-1 {
    width: 100%;
    background-color: blue;
    z-index: 1100;
}

.panel-2 {
    width: 100%;
    background-color: yellow;
    z-index: 1000;
}
<div data-target=".panel-1" class="panel panel-1 grade">
    <div class="panel-content">
       <h3>What is the concept of the project?</h3><br>
           <p>Text</p>
    </div>
</div>
 <div data-target=".panel-2" class="panel panel-2 grade">
    <div class="panel-content">
       <h3>What is the aim of the project?</h3><br>
           <p>Text</p>
    </div>
</div>
about 4 years ago · Juan Pablo Isaza
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