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
Post a Comment