Triggers an event when the div visibilty is changed.

Is there a way to trigger an event when the visibility of a div is changed?

Please, advice. It can be javascript or jquery as long as it is working.

thanks.

Joseph
LVL 8
PagodNaUtakAsked:
Who is Participating?
 
Gurvinder Pal SinghConnect With a Mentor Commented:
Or else you can set a timer interval to keep checking the visibility status of that element

var timer1 = setTimeout( "checkVisibilityStatus()", 2000); //after 2 seconds this method will be fired
var currentStatus = "none";
function checkVisibilityStatus()
{
    status = document.getElementById( "divId1" ).style.display;
    if ( status == "none" && currentStatus != status)
   {
      //do something if the div is now hidden
   }
   else if ( status == "block" && currentStatus != status)
   {
      //do something if the div is now visible
   }
   //if you want this method to fired again after two secs then
   clearTimeout( timer1 );
   timer1 = setTimeout( "checkVisibilityStatus()", 2000); //after 2 seconds this method will be fired

}
0
 
Rikin ShahConnect With a Mentor Microsoft Dynamics CRM ConsultantCommented:
You must have code to change the div visibility. Fire an event after that with your conditions. This should solve the problem.
0
 
PagodNaUtakAuthor Commented:
so, there is no event in javascript or jquery that triggers when the visibilty is changed?
0
 
Gurvinder Pal SinghConnect With a Mentor Commented:
No, there is no such event that is triggered
0
 
PagodNaUtakAuthor Commented:
Thank you for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.