HTML
<ul class="lia-list-standard" id="list_2">
<li class="label even-row"> <a href="10031/label-name/new" id="link_418" class="label-link lia-link-navigation">New<wbr></wbr></a>
<span class="label-count">1</span><span> Threads</span>
</li>
<li class="label odd-row"> <a href="/10031/label-name/Rohan" id="link_419" class="label-link lia-link-navigation">Rohan<wbr></wbr></a>
<span class="label-count">1</span><span> Threads</span>
</li>
<li class="label even-row"> <a href="10031/label-name/Rahul" id="link_420" class="label-link lia-link-navigation">Rahul<wbr></wbr></a>
<span class="label-count">1</span><span> Threads</span>
</li>
<li class="label odd-row"> <a href="10031/label-name/Preet" id="link_421" class="label-link lia-link-navigation">Preet<wbr></wbr></a>
<span class="label-count">1</span><span> Threads</span>
</li>
<li class="label even-row"> <a href="10031/label-name/Singh" id="link_422" class="label-link lia-link-navigation">Singh<wbr></wbr></a>
<span class="label-count">1</span><span> Threads</span>
</li>
<li class="label odd-row"> <a href="10031/label-name/Random" id="link_423" class="label-link lia-link-navigation">Random<wbr></wbr></a>
<span class="label-count">2</span><span> Threads</span>
</li>
<li class="label even-row"> <a href="10031/label-name/Member" id="link_424" class="label-link lia-link-navigation">Member<wbr></wbr></a>
<span class="label-count">2</span><span> Threads</span>
</li>
</ul>
Javascript
$(function(){
$('.label-count').each(function() {
$(this).after($('<span>').text(" Threads"));
});
$('.label-count').text(function(_, text) {
return text.replace(/\ ( | \) / g, '');
});
}
});
我的要求是在列表之外,我只需要显示 4 个元素并隐藏其余元素,并显示一个链接“显示更多”,当有人点击“显示更多”时,整个列表应该是可见的并且“显示更多” ”链接应该变成“少显示”,反之亦然。