javascriptmootoolsfade

Run a function on complete of div fade out using mootools


I am new to mootools and use jQuery normally.

In jQuery i know I make a function run after the effect has been completed like so.

$('#id').fadeOut(500, function(){ // Run function on complete. });

But how do you do it with mootools? So far I have:

$('id').fade('out');

Solution

  • You need to set the options for the tween/fade.

    var el = document.id('id');
    
    el.set('tween', {
        onComplete: function(){
            // Run function on complete
        }
    });
    
    el.fade(0);