2011-09-26 64 views
1

我需要更改切換div中的圖像的寬度。問題是,我有頁面中的所有圖像寬度的變化上,並且多個切換,當我點擊切換鏈接,不只是一個,我想更改切換寬度的圖像

$('.toggle').click(function() { 
$(this).prev('.guidebox').slideToggle(400); 
$('.toggle').toggleClass("active") 

if ($(this).html() === 'less') { 
     $(this).html('more'); 
     $('.guideImage img').animate({ 
      width: '187px', 
      height: '124px' 
      }, 50, function() { 
      }); 


    } else { 
     $(this).html('less'); 

     $('.guideImage img').animate({ 
     width: '300px', 
     height: '124px' 
     }, 50, function() { 
     }); 
    } 

return false; 

    }); 

}); 

回答

0
$('.guideImage img', this).animate({ 

可能在div內?

0

很難說沒有所有的代碼,但我認爲這可能工作。

變化

$('.guideImage img').animate(

$(this).prev('.guidebox').find('.guideImage img').animate(

+0

感謝。我不得不使用.parent,因爲它在外面,但現在工作:) – kristina