2011-09-26 60 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