jquery - Invoke download of a tag in html using javascript? -


currently have <a> tag has declared download attribute, this:

<a href="123.png" download >download it!</a> 

which tag above, can download image url when clicking on link. have button on page, :

<button>download using button!</button> 

is there way let user download not clicking on link clicking on button instead.

my purpose making auto code can download image specified class on html page.

using native javascript this:

html:

<a id="download-link" href="123.png" download >download it!</a> 

javascript:

document.getelementbyid("download-link").click(); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -