Callback when CSS3 transition finishes

后端 未结 5 1885
野的像风
野的像风 2020-11-22 09:30

I\'d like to fade out an element (transitioning its opacity to 0) and then when finished remove the element from the DOM.

In jQuery this is straight forward since yo

5条回答
  •  余生分开走
    2020-11-22 10:23

    Another option would be to use the jQuery Transit Framework to handle your CSS3 transitions. The transitions/effects perform well on mobile devices and you don't have to add a single line of messy CSS3 transitions in your CSS file in order to do the animation effects.

    Here is an example that will transition an element's opacity to 0 when you click on it and will be removed once the transition is complete:

    $("#element").click( function () {
        $('#element').transition({ opacity: 0 }, function () { $(this).remove(); });
    });
    

    JS Fiddle Demo

提交回复
热议问题