Thread: div id
View Single Post
  #2 (permalink)  
Old 11-23-09, 07:47 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Not tested.

HTML Code:
<head>
<script type="text/javascript">
var aDivs=array('div1','div2','div3');
var lDivs=aDivs.length-1;
var iDiv=0;
function cycle()
{
iDiv++;
if (iDiv > lDivs) iDiv=0;
/* iDiv will contain an index into the array of div ids (aDiv) */
}
</script>
</head>
<body>
<div id="div1">Div 1</div><div id="div2">Div 2</div><div id="div3">Div 3</div><br />
<button onclick="cycle()">Cycle</button>
</body>
Reply With Quote