Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Triggers an event when the div visibilty is changed.

Posted on 2011-03-24
Medium Priority
Last Modified: 2012-05-11
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.


Question by:PagodNaUtak
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 19

Assisted Solution

by:Rikin Shah
Rikin Shah earned 664 total points
ID: 35212901
You must have code to change the div visibility. Fire an event after that with your conditions. This should solve the problem.
LVL 40

Accepted Solution

Gurvinder Pal Singh earned 1336 total points
ID: 35212917
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


Author Comment

ID: 35213252
so, there is no event in javascript or jquery that triggers when the visibilty is changed?
LVL 40

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 1336 total points
ID: 35213270
No, there is no such event that is triggered

Author Closing Comment

ID: 35213511
Thank you for your help.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question