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

96
Visualizações
jquery $('.hide-show')slice(0,12).show() is not showing div properly?

i am having issue with showing data using jquery slice() and show() method to show resulting dynamic divs from php method. the code is below:

<style>
.hide-show
{
 display :none;
}
</style>
<div class="col-sm-6 col-md-3 hide-show">
<!--- rest of the code-->


</div>
<div class="col-sm-6 col-md-3 hide-show">
<!--- rest of the code-->


</div>
<div class="col-sm-6 col-md-3 hide-show">
<!--- rest of the code-->


</div>
<div class="col-sm-6 col-md-3 hide-show">
<!--- rest of the code->


</div>
<div class="col-sm-6 col-md-3 hide-show">
<!--- rest of the code-->


</div>
<div class="col-sm-6 col-md-3 hide-show">
<!--- rest of the code-->


</div>

.
.
.
.
..
and so on 

<div class="mt2 text-center load-more-btn" ">
                    <a href="javascript:void(0);" class="btn btn-blank btn-sm-width"><?php echo lang('store load more'); ?></a>
                </div>

<script>
$('.hide-show').slice(0,12).show();
 $(".load-more-btn a").click(function () {
            
              $('.hide-show:hidden').slice(0,12).show();
             
             if($('.hide-show:hidden').length == 0 )
             {
                 $(".load-more-btn a").fadeOut();
             }
        });



</script>

on initial page load it's not showing first 12 divs, which it should show , but on click its starting with first 12 divs and on words it works perfectly. can anyone please help me with this issue , sorry for my bad writing.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Place it on document.ready should fix the problem

$(document).ready(function(){
  $('.hide-show').slice(0,12).show();
});

https://jsfiddle.net/gxjm6p9e/

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