2011-04-15 35 views
0

我知道unwrap(),但是,我似乎无法让它工作。试图解开img

我双击一个img。它用div包裹,并且在这个包裹的img上方插入一个div。这是为了动画的目的。预先设定的div移动。动画完成后,我需要全部撤消。目前,我有一个条款,如果img再次被dblclicked,动画div被删除,但包装仍然存在。

$("#L .A, .B").live('dblclick', function(event) { 
    if (event.type === 'dblclick') { 
     if ($(this).hasClass('R')) { 
      $('#Box').find('.M').remove(); 
     } else { 
      $(this).wrap('<div class="MContain" />'); 
      $(this).parent().prepend('<div class="M" />'); 
      $(".M").stop().animate({ 
        marginTop : '-5px' 
       }, 400).animate({ 
        opacity : '0' 
       }, 400); 
     } 
     $(this).toggleClass('R'); 
     $('.MContain').children().unwrap(); 
    } 
}); 

任何提示?

回答

1
$(".M").stop().animate({ 
    marginTop: '-5px' 
}, 400).animate({ 
    opacity: '0' 
}, 400).queue(function() { 
    //This will be ran after the animation is done, add your code here. 
}); 
+0

@Peeter;队列对于移除动画div非常有用,但是我仍然无法解开img。我尝试从.M解包,因为它的父母与img是一样的,但也没有运气。 – 2011-04-15 18:53:28