I'm having trouble getting a transition to work when toggling a class. The class is being applied and the style changes accordingly, but the transition isn't triggering. I've checked that the transition applies to all properties, so I don't think that's the issue.
function expandFunction(element) {
element.classList.toggle("setHeightStyle");
}
.setHeightStyle {
height: 60px;
}
#expSect1 {
overflow: hidden;
cursor: pointer;
transition: 1s;
}
<div class="setHeightStyle" id="expSect1" onclick="expandFunction(this)">
<h1>Title</h1>
<br>
<p>Content!<br>More content!</p>
</div>