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

179
Visualizações
How to hide the button, that loads more elements on click if items of that type are less then 6?

I try to do it like that

 var matched = $(".gallery_thumbs .woocommerce-product-gallery__image");
 console.log(matched.length);

if ((matched < 7) && ($(window).width() > 1024)) {
  $('button.gallery_thumbs-toggle').hide();
}   

I tried the script by alert

if (($(window).width() > 1024)) {
  alert(1);
}

is working fine, but that doesn't work

if ((matched < 7)){
alert(1);
}

console.log(matched.length) is showing 2, like it is, so it's less then 7, what's wrong?

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

0

You have to check the length. So: if (matched.length < 7) instead of if (matched < 7)

function addSpan() {
  var matched = $("span");
  console.log(matched.length);

  if (matched.length < 7) {
    $("#container").html($("#container").html() + "<span>I'm a Span. </span>")
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="container">
  <button onclick="addSpan()">Add a Span</button>
  <span>I'm a Span. </span>
</div>

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