title: jQuery: extract file name from an href link when adding "download" attribute
body: <p>I am using generated html that contains a link to a file with the <code>.dxf</code> suffix:</p>
  <p><code>&lt;a href=&quot;http://example.com/filetodownload.dxf&quot;&gt;Download File&lt;/a&gt;</code></p>
  <p>Since I can't change the dynamically created html, I'm using this to add the download attribute to those href links:</p>
  <pre><code>jQuery('a[href*=&quot;.dxf&quot;]').each(function() {
  jQuery(&quot;a&quot;).attr(&quot;download&quot;, &quot;downloadedfile.dxf&quot;);
  });
  </code></pre>
  <p>This forces the browser to open a &quot;download and save&quot; dialogue.</p>
  <p>The problem is that I want the download attribute to have the name of the file in the link, i.e. <code>filetodownload.dxf</code> and not the default <code>downloadedfile.dxf</code> in the jQuery function.</p>
  <p>How can I get jQuery to use the real file name? Can I call a variable that is the actual file name? How do I extract the file name from the link?</p>
  <p>I don't want a box on the page to name the downloaded file, like <a href="https://stackoverflow.com/questions/44555950/custom-download-name-with-javascript-or-jquery">Custom download name with Javascript or JQuery</a></p>
  <p>I can't get the file name from the URL in the browser, since the file is a html download link, not a URL, like
  <a href="https://stackoverflow.com/questions/511761/js-function-to-get-filename-from-url/2480287">js function to get filename from url</a></p>