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

69
Vistas
js get the highest height of element and set all other element to this height

I have a " P Element". So the height of each element can be higher then the other. So I want that all height are the same height, but every the highest.

I get no errors but it not works.

    const getHeightAndSetNewHeight = () => {
        const k = document.querySelectorAll('.kamera');
        
        k.forEach(e => {
            if(Math.max(Number(e.offsetHeight))) {
                e.style.height = `${e.offsetHeight}px`;
    
            }
        });
    };
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to loop through once, find the maximum, then loop through again once you have it.

const getHeightAndSetNewHeight = () => {
  const k = document.querySelectorAll('.kamera');
  
  let max = -Infinity;

  k.forEach(e => {
    if (max < e.offsetHeight) max = offsetHeight;
  });
  k.forEach(e => {
    e.style.height = `${e.offsetHeight}px`;
  });
};
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