0

The following code is working fine here in sandbox and I am able to down it but in my machine and browser, using Chrome it is opening the images in next tab instead of downloading them as it is supposed to be by clicking on .imgs

Why might this happen and how can I prevent it to open in new page and just be download?

 $('section img').each(function (e) {
    var $this = $(this);
    $('#imageBox').append('<a class="imgs" href="' + $this.attr('src') + '"  download>Download</a>');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="imageBox"></div>
<section>
<img src="https://upload.wikimedia.org/wikipedia/commons/7/70/Perspolis_FC.png" alt="Smiley face" height="42" width="42">
<img src="http://pngimg.com/uploads/manchester_united/manchester_united_PNG15.png" alt="Smiley face" height="42" width="42">
</section>
halfer
  • 19,824
  • 17
  • 99
  • 186
Mona Coder
  • 6,212
  • 18
  • 66
  • 128

0 Answers0