jQuery: hide and show for div's -


i want show div 3 sec. , show next div 3 sec. , continue timer. code not working if there other code solve problem.

var timer = setinterval(showdiv(3000)); var counter = 0;  function showdiv() {   if (counter ==0)      counter++;   $('#text1, #text2').stop().hide().filter(function() {      return this.id.match('#text' + counter);    }).show();   counter == 2? counter = 0 : counter++;  } showdiv();  }); 

the filter function should return boolean value if element matches or not. here this.id.match returns array result of regular expression execution. instead of using function filter, can simplify this:

  setinterval(showdiv,3000);   var counter = 0;   function showdiv() {     if (counter ==0) { counter++;}     $('#text1, #text2')       .stop()       .hide()       .filter('#text'+counter)          .show();     counter == 2? counter = 0 : counter++;    } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -