开发者

Detecting when jQuery's hide() method is fired on an element

开发者 https://www.devze.com 2023-01-27 02:15 出处:网络
Is it possible to detect when jQuery has fired it\'s .hide() method on an element? I tried binding to the hide event on such an element:

Is it possible to detect when jQuery has fired it's .hide() method on an element?

I tried binding to the hide event on such an element:

开发者_JS百科
$('div').bind('hide', function(){
        alert("Hidden");
    })

but the alert doesn't display.


You can do it by overriding JQuery's hide method:

var oldHide = $.fn.hide;

$.fn.hide = function() {
    alert("Hidden");
    oldHide.apply(this, arguments);
}

...as shown here.


all the time? or just for debugging?

you could just use the call back function to write something to the log.

$( '#my-id' ).hide( duration, function(){ console.log( 'fired!' ); } );
0

精彩评论

暂无评论...
验证码 换一张
取 消