JSFiddle - React, Tailwind, and code Playground

by jecker

HTML

<div onClick="exportToCSV(this, 'Test.csv');">Test here</div>

JavaScript

function exportToCSV(filename) {
 csv = "test, test1, test2, test3";
 csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
  $(this)
     .attr({
         "open": filename,
         "href": csvData,
         "target": "_blank"
     });
  }