2014-10-03 82 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