Jump to content

jQuery show after time


Craig Hopson
 Share

Recommended Posts

hi guys i'm using this

<script type="text/javascript">  $('#test').addClass('js');$(function() {  var timer = setInterval( showDiv, 2000);  var counter = 0;  function showDiv() {	if (counter ==0) { counter++; return; }	$('#div1, #div2, #div3, #div4, #div5, #div6, #div7')	  .stop()		  .filter( function() { return this.id.match('div' + counter); })  	  .show('fast');	counter == 7? counter = 0 : counter++;	    }});</script>

to show #div1, #div2 ect One after another Question:- How do i make it hide them all 20 seconds after the last one shows and restart? Thanks guys

Edited by Craig Hopson
Link to comment
Share on other sites

SOLVED like this

<script type="text/javascript">  $('#test').addClass('js');$(function() {  var timer = setInterval( showDiv, 1000);  var counter = 0;  function showDiv() {    if (counter ==0) { counter++; return; }    $('#div1, #div2, #div3, #div4, #div5, #div6, #div7')	  .stop()	 	  .filter( function() { return this.id.match('div' + counter); })  	  .show('fast');	 counter == 10? counter = 0 : counter++;	 if(counter == 10){		 $('#div1, #div2, #div3, #div4, #div5, #div6, #div7').hide('slow');	 counter = 0;	 } 	  }});</script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...