0

Is this possible? I want an event to fire when this happens.

williamsandonz
  • 15,864
  • 23
  • 100
  • 186

2 Answers2

0

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.

pixelfreak
  • 17,714
  • 12
  • 90
  • 109
0

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
});
Amin Eshaq
  • 4,034
  • 1
  • 17
  • 21
  • Thanks alot for all your great answers everyone, This Live query thing like a suitable alternative, I'm not crazy on using potentailly slow plugins when its not necessary though. My reason for needing this, I want to make some additional styles after .net sends back client-side-validation. I.E the requiredfieldvalidator will trigger, but I want to also apply
  • to the LI containing the field
  • – williamsandonz Jul 01 '11 at 00:05