如何正确打开img?

问题描述 投票:0回答:1

我知道unwrap(),但是,我似乎无法让它工作。

我双击img。它用div包裹,在这个包裹内的img上面插入一个div。这是为了动画的目的。前面的div移动。

动画完成后我需要全部撤消。目前,我有一个条款,如果再次双击img,动画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();
  }
});
javascript jquery jquery-animate
1个回答
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.
});
© www.soinside.com 2019 - 2024. All rights reserved.