I need help creating a drop down banner ad with jquery

Discussion in 'jQuery' started by oseymour, Sep 9, 2009.

  1. #1
    I want to create a banner ad that when a user visits my home page, after a few seconds an image appears at the top and pushes the other elements on the page down. If the user doesn't interact by clicking on the ad and then the ad goes away after 10 or so seconds.

    I've been told that this can be done with jquery, can someone point me in the right direction.
     
    oseymour, Sep 9, 2009 IP
  2. caprichoso

    caprichoso Well-Known Member

    Messages:
    433
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    110
    #2
    You can do it with or without jQuery. Using jQuery will be easier. You have to start by catching the onLoad event and starting a timer.

    $(document).ready(function(){
     setTimeout(function() { 
       ...
       [Code to show your ad, here]
       setTimeout(function() { 
         ...
         [Code to hide your ad, here]
       }, 5000); // Time the ad is visible
     }, 2250); // Delay before displaying the ad
    
    });
    Code (markup):
     
    caprichoso, Sep 10, 2009 IP