I have a page which has a many links of files to be downloaded individually. I thought it would be a good to have feature to trigger download for all the files with a single click. Here's the script which I wrote to test this-
$('tbody tr a').slice(1).each(function(){ //don't mind the slice().
console.log('starting download of: ' + $(this).attr('href')); // for debugging.
$(this).attr('target','_blank'); // so that a new page is opened for download.
window.location.href = $(this).attr('href');
})
The problem is that the script only triggers the download of only first download link. However, if I see console, the log is printed for all the files. I think it's happening because of page redirection. Can anyone help me get around this?