I have a link for downloading Audio Files. I wish to keep it hidden and allow the user to call it using a button. But somehow I am unable to trigger the click event.
Here is HTML:
<a class="APopupDown" data-icon="home" id="DownloadFile" href="http://yahoo.com/abc.mp3" download="My File Name">Download File</a>
<button data-icon="home" href="#" onclick="DlMsg()">Download</button>
And here is the trigger.
function DlMsg()
{
alert("I am here");
$('#DownloadFile').trigger('click');
}
A Jfiddle example is here
As you can see the diredct link works but the button doesn't. Any idea what I am doing wrong?
Thanks
----- UPDATE -------
I have made the change as per Jai's suggestion. However, it now starts playing the Audio instead of downloading, whereas what I want is to use HTML5's download functionality. Here is the jsfiddle link