onHide() type event in jQuery

前端 未结 8 2174
旧巷少年郎
旧巷少年郎 2020-11-28 08:47

Does anyone know of an onHide() event or something similar in jQuery?

I tried:

$(this).bind(\'hide\', function(){
    console.log(\'asdasda\')
})         


        
相关标签:
8条回答
  • 2020-11-28 09:21

    You can pass call back function in hide function.

    function iAmCallBackForHide() { 
                 alert('I am visible after hide'); 
    }
    $('#clickMeToHide').hide( iAmCallBackForHide );
    
    0 讨论(0)
  • 2020-11-28 09:22

    For anyone finding this post two years later:

    You know exactly when the menu is visible, right?! The CSS rule tells you. So instead of relying on onShow or onHide events, you can recreate the very same rule using jQuery and rely on the very same 'hover event':

    $('ul li').hover(function () {
        // Whatever you want to do 'onShow'
    }, function () {
        // Whatever you want to do 'onHide'
    });
    

    Also, your script now acts independent of any stylesheet, so that presentation details do not dictate website behavior (nice).

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