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

140
Vistas
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 Respuestas
Responde la pregunta

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