Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onHide() type event in jQuery

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

I tried:

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

But apparently that doesn't work.

Edit:
Just to clarify, it's being hidden using CSS display:none.
I'm aware of the callback function but as I'm not hiding it (the CSS is) I can't use it. For what it's worth, I need to check when a dropdown is visible. It's being shown by the following CSS:

ul li:hover ul {     display: block; }  
like image 906
Sam Avatar asked May 18 '10 13:05

Sam


People also ask

What is OnHide?

The OnHide event occurs when the user form is hidden. This happens when the form's Hide method is called or the Visible property is set to False. You can create an event handler for the OnHide event to perform certain actions when the form is hidden.

What will the jQuery code $( P hide (); do?

jQuery hide() Method The hide() method hides the selected elements. Tip: This is similar to the CSS property display:none. Note: Hidden elements will not be displayed at all (no longer affects the layout of the page).

How do I hide a div?

The document. getElementById will select the div with given id. The style. display = "none" will make it disappear when clicked on div.


2 Answers

There isn't a native or built in "hide" event but if you are using jQuery to hide it you can easily add a hide event:

var _oldhide = $.fn.hide; $.fn.hide = function(speed, callback) {     $(this).trigger('hide');     return _oldhide.apply(this,arguments); } 
like image 122
PetersenDidIt Avatar answered Sep 21 '22 04:09

PetersenDidIt


You can pass call back function in hide function.

function iAmCallBackForHide() {               alert('I am visible after hide');  } $('#clickMeToHide').hide( iAmCallBackForHide ); 
like image 34
Faisal Ahsan Avatar answered Sep 23 '22 04:09

Faisal Ahsan