Posted By

Piotrek290 on 08/29/09


Tagged

javascript foreach


Versions (?)

Foreach


 / Published in: JavaScript
 

Use:

foreach([ document.getElementById('pole1'), document.getElementById('pole2'), document.getElementById('pole3') ], function(obj){ obj.style.borderColor = 'green'; });

  1. function foreach(array, callback){
  2. for(var i=0; i<array.length; ++i){
  3. callback(array[i]);
  4. }
  5. }

Report this snippet  

You need to login to post a comment.