mardi 4 août 2015

On button click put all elements src to array

I have many divs with id="imgLinks"

<div><img  id="imgLinks" u=image src="../../../../images/1.jpg" /></div>
<div><img  id="imgLinks" u=image src="../../../../images/3.jpg" /></div>
<div><img  id="imgLinks" u=image src="../../../../images/5.jpg" /></div>

I need on button click put all src to array

$(document).on('click', '#navigation #Download', function() {
    var imgLinks = [];
        $("#imgLinks").each(function() {
            var name = $(this).attr("src");
            imgLinks.push(name);
        });
});

But this code put only first source, how to put all of them?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire