JSFiddle - React, Tailwind, and code Playground

by Eugene Fedorov

HTML

<a class="selector" href="#"> Download </a>

JavaScript

$(function() {
	$('a.selector').click(function() {
        text = 'file content';
        type = 'text/plain';
        name = 'file name';
        var a = document.createElement("a");
        var file = new Blob([text], {type: type});
        a.href = URL.createObjectURL(file);
        a.download = name;
        a.click();
    })
})