gpt4 book ai didi

javascript - Jquery else if 语句似乎不起作用

转载 作者:行者123 更新时间:2023-11-30 11:18:02 26 4
gpt4 key购买 nike

<分区>

我有一个 else if 语句,它根据 div 中的字符数显示或隐藏阅读更多按钮。

实际的 if 语句似乎有效 - 它删除了阅读更多按钮,但 else if 似乎不起作用。

我的代码如下

$('.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);
}

如有任何帮助,我们将不胜感激。

谢谢

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com