2014-10-03 81 views
0

我一直在研究手风琴,并将其与我需要的接近。但是,在点击关闭“x”图标后,我似乎无法将箭头旋转回0度。切换关闭,但箭头停留在向下的位置。当点击“x”关闭图标时,有箭头切换回(0deg)

FIDDLE

$('#main').each(function() { 
     var $accordian = $(this); 
     $accordian.find('.view-m').on('click', function() { 
      $accordian.find('.mobile-content-body').slideUp(); 
      $accordian.find('span').css('transform', 'rotate(0deg)'); 
      if (!$(this).next().is(':visible')) { 
       $(this).next().slideDown(); 
       $(this).find('span').css('transform', 'rotate(90deg)'); 
       $(this).next().slideDown(); 
       $accordian.find('.close').click(function() { 
        $(this).parent().slideUp(500); 
        $(this).find('span').css('transform', 'rotate(0deg)'); 
       }); 
      } 
     }); 
    }); 

回答

1

的问题是在这条线:

$(this).find('span').css('transform', 'rotate(0deg)'); 

您正在搜索的箭头的X按钮。你需要去2元了,和搜索有:这一行

$(this).find('span').css('transform', 'rotate(0deg)'); 

Fixed Fiddle

$('#main').each(function() { 
     var $accordian = $(this); 
     $accordian.find('.view-m').on('click', function() { 
      $accordian.find('.mobile-content-body').slideUp(); 
      $accordian.find('span').css('transform', 'rotate(0deg)'); 
      if (!$(this).next().is(':visible')) { 
       $(this).next().slideDown(); 
       $(this).find('span').css('transform', 'rotate(90deg)'); 
       $(this).next().slideDown(); 
       $accordian.find('.close').click(function() { 
        $(this).parent().slideUp(500); 
        $(this).parent().parent().find('span').css('transform', 'rotate(0deg)'); 
       }); 
      } 
     }); 
    }); 
0

变化与

$(this).parent().prev('.view-m').find('span').css('transform', 'rotate(0deg)'); 

DEMO