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

149
Views
¿Cómo filtro una matriz por tipo de visualización si el tipo de visualización se establece mediante arranque?

Estoy tratando de filtrar una serie de tarjetas de cartera para poder ver qué elementos se muestran o no.

 let pfCard = document.getElementsByClassName("PortfolioCard") const visibleCards = [...document.getElementsByClassName("PortfolioCard")].filter(x => x.style.display != "none"); console.log(visibleCards.length);

Las tarjetas mostradas tienen la visualización establecida en ninguno por una clase de arranque cuando se cumple la consulta de medios. El código que he estado tratando de ejecutar aún captura todos los elementos de la matriz sin importar el tipo de visualización. Hay 8 elementos en la matriz y 2 están configurados para display: none; corrientemente.

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

0

Debido a que la propiedad de visualización del elemento la establece el archivo CSS, deberá obtener el estilo calculado mediante window.getComputedStyle :

 let pfCard = document.getElementsByClassName("PortfolioCard") const visibleCards = [...document.getElementsByClassName("PortfolioCard")].filter((x) => { return window.getComputedStyle(x).display != "none" }); console.log(visibleCards.length);
 .PortfolioCard { width: 100px; height: 100px; background: red; margin: 10px; } .PortfolioCard:nth-child(3) { display: none; }
 <div class="PortfolioCard"></div> <div class="PortfolioCard"></div> <div class="PortfolioCard"></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!