-5

これまでのところ、jQueryで onHide() タイプのイベントを試しました

4

3 に答える 3

3

このプラグインは、スタイルの変更を検出して通知することができます: jQuery Style Listener

次のように使用できます。

$('#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
        }
    }

});

デモ: http://jsfiddle.net/vaxQX/

免責事項: 私はプラグインの作成者です。

于 2013-01-12T05:28:21.503 に答える
0

非表示になる関数にコールバック関数を提供できます。

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

これが希望どおりに機能するかどうかはわかりませんが、関数は非表示が完了すると起動します。

于 2013-01-12T05:26:13.483 に答える
0

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!' );
   });
});

または古典的な方法で:

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

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

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

于 2013-01-12T05:26:22.637 に答える