javascript - jQuery question about looping through an array -


i have array this:

var gridarray = [ 1,2,0,1,2,3,2,1,2,3,4,4,3,2,2,2,0 ] 

and jquery each() function this:

$('li.node').each(function() {                 loop through array                             var rndtile = current array digit                  $(this).css({ 'background-image': 'url(images/'+arraydigit+'.jpg' });             }); 

how implement this?

you need pass parameters each callback.

$(gridarray).each(function (i, val) {   // index in loop.   // val value @ gridarray[i] in loop. }); 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -