I need something like enumerate in python, but in JQuery.
I have this small snippet:
array_of_urls = [....];
items = $('p[id^="gallery_thumb"]'); // get all <p> which id begins with gallery_thumb
for(var i=0; i<items.length; i++) {
// something something with items, i and array_of_urls
// like:
items[i].load( array_of_urls[i] );
}
is there a way to avoid the for loop and do it inline? like a mix between jquery .each and enumerate in python..
or some cleaner way to face a problem like this..
The
eachmethod gives you an index that you can use to access the array: