0

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.

0

2 Answers 2

1
 arrayOfHTMLImageElements =    $('#gallery_container img').get();
 orJqueryCollectionOfImages = $('#gallery_container img');
 arraySourcesOfImages =   $('#gallery_container img').map( function(){ return this.src })
Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

jQuery objects store matched elements in an Array. $('.some_img').get() will return an Array of all the matched HTMLElements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.