javascript - How do I make a loop? -


i have php array writes <div id="first_<?php echo $z; ?>" class="source">

i'm trying create loop in javascript can change style.display property of each. total amount of first_s can anywhere 0 100.

all know how this:

function setup() {     cow = document.getelementbyid('first_1');     cow.style.display='none';     cow = document.getelementbyid('first_2');     cow.style.display='none';     cow = document.getelementbyid('first_3');     cow.style.display='none';   } 

my guess on how this:

for (var = 0; < 100; i++) {      cow = document.getelementbyid('first_'var i);     cow.style.display='none'; } 

for (var = 0; < 100; i++) {    var cow = document.getelementbyid('first_' + (i + 1));   if (cow)     cow.style.display='none'; } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -