JSFiddle - React, Tailwind, and code Playground

by dipeshbeckham

JavaScript

function downloadMultiplePdfs(pdfs) {
  const pdf = pdfs.pop();

  const a = document.createElement("a");

  a.setAttribute('href', pdf);
  a.setAttribute('download', '');
  a.setAttribute('target', '_blank');
  a.click();

  if (pdfs.length == 0) {
    clearInterval(interval);
  }
}

const pdfs = [
  'https://google.com',
  'https://yahoo.co.in',
  'https://bing.com'
]

var interval = setInterval(downloadMultiplePdfs, 500, pdfs);