在条件下使用 slideUp() 和 slideDown()

Using slideUp() and slideDown() in condition

本文关键字:slideDown slideUp 条件下      更新时间:2023-09-26
<div class='head'>
      <img class='img_plus'> <img class='img_minus'>
</div>
<div> div next head</div>

在手风琴中,我想检查头部旁边的div 是否向上滑动,它显示 .img_plus (+( 到头部,否则如果div 下一个头部向下滑动,它会隐藏 (+( 并显示.img_minus (-(

$(".head").each(function(){                 // For each .head element
   $(this).find("img").hide();              // Hide all icons first
   var $nextDiv = $(this).next("div");      // Get the next DIV element
   if( $nextDiv.is(":visible") ) {          // If next DIV is visible
      $(this).find(".img_minus").show();    // Show the - icon
   }else{                                   // Else
      $(this).find(".img_plus").show();     // Show the + icon
   }
});