Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery event handler: div becomes visible/hidden

Tags:

jquery

I have a div and I'd like to have an event handler listen to when it becomes visible and hidden. How do you do that?

Thanks.

like image 520
frenchie Avatar asked Feb 09 '11 17:02

frenchie


1 Answers

You can use the callback parameter in the show() and hide() methods like this:

$('#myDiv').show(0, onDivShow);
$('#myDiv').hide(0, onDivHide);

function onDivShow() { //your code here }
function onDivHide() { //your code here }

See a working example here: http://jsfiddle.net/N7UNU/

like image 146
treeface Avatar answered Sep 27 '22 18:09

treeface