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

65
Views
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 answers
Answer question

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 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!