I need help adjusting the toggle button in my code. Currently, it works well without the 'if' condition, but I want it to hide when there is less data and appear when there is more data. Additionally, I want to set a minimum height of 100px for the content div. Could someone assist me with this? Thank you.
https://i.sstatic.net/T2X09.pnghttps://i.sstatic.net/lQF7E.pnghttps://i.sstatic.net/pBYrn.png
var elmnt = document.querySelector(".backwhite");
var txt = elmnt.clientHeight + "px";
if (txt >= 100 + "px") {
var mydivh = document.querySelector(".backwhite");
mydivh.style.height = "100px";
function toggleDescriptionHeight(e) {
document.querySelector(".backwhite").classList.toggle('expanded');
e.target.textContent == 'Expand' ? e.target.textContent = 'Collapse' : e.target.textContent = 'Expand';
}
var button = document.querySelector('.btn');
button.addEventListener('click', toggleDescriptionHeight)
} else {
var myElements = document.querySelector(".bbttnn");
myElements.style.display = "none";
var myElement = document.querySelector(".backwhite");
myElement.style.height = "100px";
}
body {
background-color: #f1f3f6;
}
.backwhite {
background-color: #fff;
padding: 15px;
overflow: hidden;
}
.backwhite.expanded {
height: auto;
}
<div class="container">
<h4>Description</h4>
<div class="backwhite">
<p>1. Create Ui For Email Campaign.</p>
<p>2. Create Functionality of Email Campaign</p>
<p>3. Create Keyword Display using Drag And Drop Functionality.</p>
<p>1. Create Ui For Email Campaign.</p>
<p>2. Create Functionality of Email Campaign</p>
<p>3. Create Keyword Display using Drag And Drop Functionality.</p>
<p>1. Create Ui For Email Campaign.</p>
<p>2. Create Functionality of Email Campaign</p>
<p>3. Create Keyword Display using Drag And Drop Functionality.</p>-->
</div>
<button type="button" class="btn btn-default btn-block">Expand</button>
</div>