JSFiddle - React, Tailwind, and code Playground

by beneverard

HTML

<a class="download" href="http://domain.com/data/jbloggs/test.pdf?downlodad">Click to Download</a>

JavaScript

$(document).ready(function() {
   
    $('a.download').click(function(event) {
    
        // aha! this is a downloadable link. Change
        // the url to force the download instead of viewing
        
        // this is still a shit method, I wish chrome's a[download]
        // attribute gets adopted by others soon :-(
        
        $(this).attr('href', '/download.php?file=' + $(this).attr('href'));
        
    });
    
});