I have a question about displaying content within a div element. I want to show a "show more" button only if the content inside the div exceeds a max height of 530px. Otherwise, the button should remain hidden.
Here is the code snippet I'm using:
Javascript
var clientHeight = document.getElementById('ccontainer').clientHeight;
if (clientHeight >= 530) {
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>