Custom jQuery event listener that triggers on show()
I have a div that gets hidden and displayed, via .hide() and .show(). When it is displayed by .show() I need it t开发者_如何学编程o 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.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论