I have an else if statement which is to show or hide a read more button depending on the number of characters within the div.
The actual if statement seems to work - which removes the read more button but the else if doesn't seem to be working.
My code is below
$('.hotel-copy').each(function () {
if ($(".sidebar-box").length < 194) { // if count is less than 193
$(".read-more").hide();
}
else if ($(".sidebar-box").length > 194) { // if count is greater than 193
$(".read-more").show();
}
});
HTML
<div class="hotel-copy">
<div class="sidebar-box">
@if (!string.IsNullOrWhiteSpace(hotel.Description))
{
<p>@hotel.Description</p>
<p class="read-more"><a href="javascript:void(0);" class="button">Read more</a></p>
}
</div>
</div>
CSS
/* READ MORE */
.accommodation-container .sidebar-box {
height: 120px;
position: relative;
overflow: hidden;
}
.accommodation-container .sidebar-box .read-more {
position: absolute;
bottom: 0px;
left: 0;
width: 100%;
/* text-align: center; */
margin: 0;
padding: 20px 0 0px 0;
background-image: linear-gradient(to top, #f7f7f7, #f7f7f7);
}
Any help would be much appreciated.
Thanks