开发者

Jquery listener on an element when it display:block/none; property changes

开发者 https://www.devze.com 2023-03-16 09:19 出处:网络
Is this possible? I want an event开发者_如何学JAVA to fire when this happens.Hmm, why do you need this? Instead, I would suggest thinking about what causes the element to be shown/hidden and react to

Is this possible? I want an event开发者_如何学JAVA to fire when this happens.


Hmm, why do you need this? Instead, I would suggest thinking about what causes the element to be shown/hidden and react to that. It's always better to decouple your logic from view.

But if you still really want to do this, the only way I can think of right now is to have an interval that keeps polling for the element's visibility.


you could use livequery to do this.

$('div.myClass:hidden').livequery(function(){
//do something when hidden
});
$('div.myClass:visible').livequery(function(){
//do something when visible
});
0

精彩评论

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