2012-05-09 84 views

回答

1

您需要使用的animate()回調函數參數的message DIV追加到相關box。你也應該使用hover。試試這個:

$('.box').hover(
    function() { 
     var $box = $(this); 
     $box.stop().animate(
      { width: '280px', height: '420px'}, 
      650, 
      function() { 
       var $div = $("<div></div>").addClass("message").text("Message text"); 
       $box.append($div); 
       $div.fadeIn(); 
      } 
     ); 
    }, 
    function() { 
     var $box = $(this); 
     $(".message", $box).fadeOut(function() { 
      $box.stop().animate({ width: '100px', height: '100px' }, 650); 
     });   
    } 
); 

Example fiddle