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.
You can use the callback parameter in the show() and hide() methods like this:
show()
hide()
$('#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/
2.1m questions
2.1m answers
60 comments
57.0k users