jquery event handler: div becomes visible/hidden

前端 未结 2 1685
执念已碎
执念已碎 2020-12-11 15:43

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.

相关标签:
2条回答
  • 2020-12-11 15:51

    You can create a trigger. You would, of course, have to fire the trigger, but that is one way to do it.

    0 讨论(0)
  • 2020-12-11 16:13

    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/

    0 讨论(0)
提交回复
热议问题