Monday 15 July 2019

Javascript - iterating throught array



Hi i have following code



$(args.data0).find('group').each( function() ...



Variable args is create by AJAX call and it contains data0, data1, ... dataN
How can i programatically iterate over all these variables?
Something like that packed in some kind of forEach cycle :)



$(args.data0).find('group').each( function() ...
$(args.data1).find('group').each( function() ...
$(args.dataN).find('group').each( function() ...


Many thanks



Answer



for(var i = 0; i <= n; i++){
$(args['data' + i]).find('group').each( function() ...
}

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...