I have a container with a button labeled "Show more". Upon clicking the button, the height of the container will transition through 3 different states.
<div class="segment-suggestion-content height-small">
<div class="segment-suggestion-show-more">
<button type="button" class="btn">Show More</button>
</div>
</div>
Initially, the container has the class .height-small with a height of 200px. When the "show more" button is clicked, the .height-small class will be removed and replaced with .height-mid, which has a height of 400px. Subsequently, clicking on 'show more' once again will remove the .height-mid class and add .height-full. Clicking 'show more' for the final time will change the container back to .height-small.
Although I am not proficient in jQuery, I attempted the code below, but it isn't functioning correctly. I'm uncertain as to what the issue might be.
$('.segment-suggestion-show-more .btn').click(function(){
if($(".segment-suggestion-content").hasClass('height-small'))
{
$(".segment-suggestion-content").removeClass('height-small');
$(".segment-suggestion-content").addClass('height-md');
}
if($(".segment-suggestion-content").hasClass('height-md'))
{
$(".segment-suggestion-content").removeClass('height-md');
$(".segment-suggestion-content").addClass('height-full');
}
if($(".segment-suggestion-content").hasClass('height-full'))
{
$(".segment-suggestion-content").removeClass('height-full');
$(".segment-suggestion-content").addClass('height-small');
}
});
Any assistance would be highly appreciated.