I append an <a> tag with a href with a download attribute.
$('<a>Download</a>').attr({
download: 'testing.svg',
href: dataUrl,
id: 'download',
name: 'test'
// style:'display:none'
}).appendTo("body");
This is my code and I want to trigger the click event:
$('#download').trigger( "click" );
This is not working because it is an appended element.
I tried to use window.open(href,'_blank'); but if I run this statement, the file is not downloading. It just opens a new tab.
How can I download file without redirect?