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

132
Views
how to hide an element based on the height of another element

i have a div and a show more button for it and i want to hide the show more button if the things in the div don't exceed the max height of the div (530px) because i won't need the button unless things in the div exceed it's max height.

my code

Js

var clientHeight = document.getElementById('ccontainer').clientHeight;
if clientHeight => '530px' var x = 1 else var x = 0
if x = 1 { div.classList.add('show');}

Html

<div class="ccontainer" id="ccontainer">
  <p id="context"> content </p>
  <div class="img" id="cntimgcon" >
    <img src="images\image2.jpg" id="cntimgp1">
  </div>
  <p id="context"> content </p>
</div>
<Button class="showmore"> show more </button>
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

const btn = document.querySelector('.showmore');
const height = document.querySelector('#ccontainer').clientHeight;

if (height <= 530) {
  btn.style.display = 'none'; // hide
} else {
  btn.style.display = ''; // unhide
}
about 4 years ago · Santiago Gelvez 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!