Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
¿Cómo ocultar el botón, que carga más elementos al hacer clic si los elementos de ese tipo son menos de 6?

trato de hacerlo asi

 var matched = $(".gallery_thumbs .woocommerce-product-gallery__image"); console.log(matched.length); if ((matched < 7) && ($(window).width() > 1024)) { $('button.gallery_thumbs-toggle').hide(); }

Probé el script por alerta.

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

está funcionando bien, pero eso no funciona

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

console.log(matched.length) muestra 2, tal como es, por lo que es menos de 7, ¿qué pasa?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tienes que comprobar el length . Entonces: if (matched.length < 7) en lugar de 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!