click on “download” link using JQuery doesn't download file [duplicate]
问题 This question already has answers here : Download image with JavaScript (2 answers) Closed 6 years ago . I have a link with href and download attributes: <a id="lnk" href="data:text/csv;charset=utf-8,1%2C2%2C3" download="my_file.csv">click to download</a> When I click on it (in Chrome for example) a csv file "my_file.csv" is downloaded as supposed. Now I want to be able to cause this action programmatically. So using JQuery I am trying to do: $('#lnk').click(); or $('#lnk').trigger("click");