Web Analytics Made Easy -
StatCounter How to trigger function when div is visible? - CodingForum

Announcement

Collapse
No announcement yet.

How to trigger function when div is visible?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to trigger function when div is visible?

    How can I trigger a function when a div or that div's parent display property changes from hidden to block? I've tried using jQuery but couldn't find or think of anything to accomplish my goal. Anyone have suggestions/ideas?

  • #2
    Presumably like this:-

    Code:
    <div id = "div1" style="display:none">The message here</div>
    
    <script type = "text/javascript">
    function show() {
    document.getElementById("div1").style.display = "block"
    alert ("You can put more code in here");
    //  additional code
    
    }
    You cannot otherwise detect that the style has changed.



    Quizmaster: In Roman Catholicism, baptism, confirmation and matrimony are three of the seven what?
    Contestant: Deadly sins.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

    Comment


    • #3
      The catch is the function that displays the previously hidden div is a "tab" js function from jQuery. I tried binding a function to this "tab" via jQuery as below, but the "bound" function would not fire on tab selection. Any ideas on how to fix/resolve this? Thanks.

      Code:
      $('#sortImages').bind('tabselect', function(){ var params = "type=displayThumbnails";
                          var url = "createThumbs.php";
                          Ajax.post(params, url, false);
                          if (typeof(Ajax.response) == "undefined"){
                                 alert("Ajax response error");
                          } else {
                              document.getElementById("thumbnailContainer").innerHTML = Ajax.response;
                           }
                          });

      Comment

      Working...
      X