how can i achieve the following with a button tag:
<a id="download" href="a.jpg" download="a.jpg">Download</a>
P.S: when you click on the button, it should download the a.jpg file and NOT open it in the browser.
how can i achieve the following with a button tag:
<a id="download" href="a.jpg" download="a.jpg">Download</a>
P.S: when you click on the button, it should download the a.jpg file and NOT open it in the browser.
 
    
    You want Content-Disposition: attachment; in the backend. You'll need a script handing out the images to force a download.
 
    
    You can add the attribute download, which is new to HTML5 and is supported by Firefox and Chrome but not yet IE or Opera:
<a id="download" href="a.jpg" download="a.jpg">Download</a>
 
    
    Solution for modern browsers
With image link
<a href="a.jpg" download="imageName"><img src="images/a.jpg" alt="Image"/></a>
With text link
<a href="a.jpg" download="imageName">Download Image</a>
 
    
    <a   href="test.png"  download  ><input type="button" id="btn1"     onclick="saveAsImg(document.getElementById('chart_div'));" title="Download Png"  /></a>
find parent of id="btn1"  
like  $("#btn1").parent().get(0).href=$("img1").src;
 
    
    In some cases does not work
<a id="download" href="a.jpg" download="a.jpg">Download</a> 
because, server don't want to anyone download content normally method. so we needed force download method.
I think you should
Try this