Any method like onshow () for a div

I have a div that displays or hides dynamically. I want some function to be executed when the div is shown for the first time. Let me know how to do this.

<div id="firstDiv"></div>
<div id="secondDiv"></div>

so when $('#secondDiv").show(); I want to perform some function.

How can i do this?

+3
source share
1 answer

You can provide a function callback function showthat will be executed upon completion show:

$("#secondDiv").show(function() { 
    //Do something 
});

, . , show (.. ), 0 show. .

+8

All Articles