Home > Software engineering >  What is the best way to download mulitple images using jquery
What is the best way to download mulitple images using jquery

Time:05-11

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  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?

CodePudding user response:

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();
    });
  }
  • Related