Jquery link to show divs in sequence one at a time? -


i have page 5 divs. 1 of them shown default - other 4 hidden css. have button i'd able click , show div one @ time in sequence. in other words... 1st click of link shows div #2, second click adds div #3, third click show div #4 , final click have 5 divs visible.

i'm fine show/hide aspect how can link move on show next div in sequence?

a simple way implement number divs assigning ids div1, div2, div3 ...

then it's matter of keeping track of count of visible divs. in click event handler of button, increment count , generate id of next div displayed.

also add check see if count of visible divs equal total divs displayed.

var visibledivscount = 1; var totaldivscount = 5   function displaynextdiv() {             if(visibledivscount < totaldivscount)     {         visibledivscount += 1;         $("#div"+visibledivscount).show();     } }   $("#button").click(function(){     displaynextdiv(); }); 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -