-5

So far I tried onHide() type event in jQuery

Community
  • 1
  • 1
Ishan Jain
  • 8,063
  • 9
  • 48
  • 75

3 Answers3

3

This plugin will be able to detect the style change and notify you: jQuery Style Listener

You can use it like:

$('#yourElement').styleListener({

    // the styles that you want to monitor for changes
    styles: ['display'],

    // function to be called when a monitored style changes 
    changed: function(style, newValue, oldValue, element) {

        if(style == 'display' && newValue == 'none') {
            // element got hidden, do your stuff
        }
    }

});

Demo: http://jsfiddle.net/vaxQX/

Disclaimer: I am the author of the plugin.

techfoobar
  • 65,616
  • 14
  • 114
  • 135
0

You can provide a callback function on the function that gets hidden.

$('div').hide(function(){
    // do something
});

Not sure if this will work for what you want, but the function will only fire once hide is complete.

PlantTheIdea
  • 16,061
  • 5
  • 35
  • 40
0

you can use http://api.jquery.com/promise/ :

http://jsbin.com/evajiv/1/edit

$('#test').click(function(){
   $(this).hide();      // I USED .fadeTo() in the demo
   $(this).promise().done(function(  ) {
       alert( 'HIDDEN!' );
   });
});

or in a classic way:

function fn(){
   alert('DONE!');
}

$('#test').click(function(){
   $(this).hide(fn);  // use callback
});

http://jsbin.com/evajiv/3/edit

Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313