开发者

Detecting when jQuery's hide() method is fired on 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜