在 jquery 中向上滑动 div
Sliding Up divs in jquery
我有以下 div
<div class="OffersContainer">
<div class='special'>A</div>
<div class='notspecial'>B</div>
<div class='notspecial'>C</div>
<div class='notspecial'>D</div>
<div class='notspecial'>E</div>
<div class='notspecial'>E</div>
<span>Show more</span>
</div>
点击 span 时,我想向上滑动,以便只有具有 class 'notspecial' 的前 3 个 div 可见。
我尝试了以下代码,但它以错误的顺序向上滑动
$(offers).filter("div.notspecial:lt(4)").slideUp();
$(".OffersContainer > span").on("click", function(){
$(".special, .notspecial:gt(2)").slideUp();
});//
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="OffersContainer">
<div class='special'>A</div>
<div class='notspecial'>B</div>
<div class='notspecial'>C</div>
<div class='notspecial'>D</div>
<div class='notspecial'>E</div>
<div class='notspecial'>E</div>
<span>Show more</span>
</div>
我有以下 div
<div class="OffersContainer">
<div class='special'>A</div>
<div class='notspecial'>B</div>
<div class='notspecial'>C</div>
<div class='notspecial'>D</div>
<div class='notspecial'>E</div>
<div class='notspecial'>E</div>
<span>Show more</span>
</div>
点击 span 时,我想向上滑动,以便只有具有 class 'notspecial' 的前 3 个 div 可见。 我尝试了以下代码,但它以错误的顺序向上滑动
$(offers).filter("div.notspecial:lt(4)").slideUp();
$(".OffersContainer > span").on("click", function(){
$(".special, .notspecial:gt(2)").slideUp();
});//
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="OffersContainer">
<div class='special'>A</div>
<div class='notspecial'>B</div>
<div class='notspecial'>C</div>
<div class='notspecial'>D</div>
<div class='notspecial'>E</div>
<div class='notspecial'>E</div>
<span>Show more</span>
</div>