Reputation: 162
I need to do an image array for a gallery, The gallery has around 10-20 images I'm just unsure on how to actually make an image array in jQuery.
Any help would be greatly appreciated.
Upvotes: 0
Views: 1107
Reputation: 5042
arrayOfHTMLImageElements = $('#gallery_container img').get();
orJqueryCollectionOfImages = $('#gallery_container img');
arraySourcesOfImages = $('#gallery_container img').map( function(){ return this.src })
Upvotes: 1
Reputation: 6536
Put the images in <div class="some_img">
, and then:
var m = []
$('.some_img').each(function() { m.push ($(this));});
Don't actually use that code; format it first, but, that's the general idea.
Upvotes: 0