Skip to content

Latest commit

 

History

History
30 lines (26 loc) · 878 Bytes

File metadata and controls

30 lines (26 loc) · 878 Bytes

JQuery.waitElement

Wait Element exist and be visible on the screen to execute a function. Case timeout, executes a "fail function"

$(selector).waitElement([fn,fnFail,time])

  1. fn: function, "sucess function" (optional)
  2. fnFail: function, "fail function" (optional)
  3. time: number "seconds", (default "30s")

#[Example]

  $(document).ready(function(){
          $("body").append("Creating...");
          setTimeout(function(){
              $("body").append("<div class='box'></div>");
          },5000);
          $("div").waitElement(function(){
              $("body").append("Created.");
          });
          $("a").waitElement(function(){
              $("body").append("a element");
          },function(){
              $("body").append("Element 'a' not found");
          },10)
      }
  );

MIT License