Thursday, April 21, 2011

jquery slide and timing

hey there, i have a div that expands when the page is loaded, now i need it to collapse after 30 seconds, does anybody have an idea about how to do it in query?

$(function(){
 $("#banner").slideDown(); 
 });
From stackoverflow
  • To do this you'll need to use setTimeout

    $(function(){
            //something
            setTimeout("slidedown()",30000);
    }
    
    function slidedown(){
       $("#banner").slideDown()
    }
    
  • $(function(){
        $("#banner").slideDown(function() {
            setTimeout(function() {
                $("#banner").slideUp();
            }, 30000);
        });
    });
    
    Andy : i forgot to say thank you! sorry i was on a hurry, now that i see the function it was kind of obvious isn´t it?? xD it works really nice. thanks a lot for the help!
  • There are also plugins for jQuery that will pause/delay execution.

0 comments:

Post a Comment