I have a div
that gets hidden and displayed, via .hide()
and .show()
. When it is displayed by .show()
I need it to do some stuff. Is there any way I can setup a custom event listener that fires a callback when the div
goes from hidden to visible? I can make a function and call it wherever I would call $(#myDiv").show()
but that happens in multiple places and I would like to keep this all in one place.
You can pass a function callback into the show method which will execute after the show has completed:
$("#myDiv").show(function(){
myCustomFunction();
});
You could use you own function instead of the internal "show" with a specific callback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With