-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 回答