Solved

Triggers an event when the div visibilty is changed.

Posted on 2011-03-24
5
368 Views
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.

thanks.

Joseph
0
Comment
Question by:PagodNaUtak
  • 2
  • 2
5 Comments
 
LVL 19

Assisted Solution

by:Rikin Shah
Rikin Shah earned 166 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.
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 334 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

}
0
 
LVL 8

Author Comment

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

Assisted Solution

by:gurvinder372
gurvinder372 earned 334 total points
ID: 35213270
No, there is no such event that is triggered
0
 
LVL 8

Author Closing Comment

by:PagodNaUtak
ID: 35213511
Thank you for your help.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
dynamics crm 2011 - Web Resources 1 26
Run Script only if a div is in the viewport 6 31
getting id from database 5 24
onOpen 14 42
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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 invoke it on a web page. 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.: (CODE)

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now