Skip to content
Advertisement

What is the best way to download mulitple images using jquery

I have a section in which I have multiple images now on click I would like to download all.

Here is what my images look like

enter image description here

and here is how I am downloading those images using jquery

HTML

<button class="button" onclick="downloadImages()">Download</button>

JS

function downloadImages(){
    let link =  $(".grcode-image");
    console.log('link', link)
    link.click();
}

When I click the download button only I see is the console log

enter image description here

What am I doing wrong here? and what do I need to do to be able to download all images at once?

Advertisement

Answer

If you only need download the images without zip:

Just map the array and click:

function downloadImages() {
    $(".grcode-image").each(function (index, currentElement) {
      currentElement.click();
    });
  }
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement