我知道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();
}
});
$(".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.
});