使用jquery爆炸动画

时间:2011-11-09 22:40:37

标签: jquery image animation explode

我有一个带有span标签的容器,如果我点击span元素,我需要有一个爆炸动画,并删除该元素。

我可以使用淡入淡出效果,但我不知道如何使用爆炸效果,如果使用这种方式它只是删除没有任何动画:

的CSS:

#container a span { display:none; background-image:url(images/remove.png); background-repeat:no-repeat; width:16px; height:16px; position:absolute; right:0px; top:0px;} 
#container a:hover span { display:block;}  

淡化效果:

  $('.container a span').live('click', function (e) {
                $(this).closest('div.container').fadeOut("normal", function () {
                  $(this).remove();
                                });
                return false;
   });

爆炸效果

$('.container a span').live('click', function (e) {
                    $(this).closest('div.container').fadeOut("normal", function () {
                    $(this).hide('explode', { pieces: 25 }, 600);
                      $(this).remove();
                                    });
                    return false;
});

这些是在我绑定的地方动态添加的图像,如下所示:

 uploader.bind('FileUploaded', function (up, file, res) {
            $('#container').append("<div class='container a'><a href='#'><img src='uploads/" + document.getElementById("currentDirectory").value + "/" + file.name + "' width='64' height='64'/><span></span></a></div>");

            $('.container a span').live('click', function (e) {
                $(this).closest('div.container').fadeOut("normal", function () {
                    $(this).remove();
                });
                return false;
            });
});

这是我展示图片的地方:

 <div id="container">

  </div>

1 个答案:

答案 0 :(得分:5)

I think this is what you want?

$('.container a span').live('click', function (e) {
    $(this).hide('explode', { "pieces":25 }, 600, function() { $(this).remove; });
    return false;
});