Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
How do I filter an array by display type if display type is set by bootstrap?

I am trying to filter an array of portfolio cards so that I can see which items are displayed or not.

let pfCard = document.getElementsByClassName("PortfolioCard")

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

The displayed cards are having the display set to none by a bootstrap class when the media query is met. The code I have been trying to run still grabs all the elements in the array no matter the display type. There are 8 elements in the array and 2 are set to display: none; currently.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Because the element's display property is set by the CSS file, you'll need to get the computed style using 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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda