Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js setattribute download

// this will download on click
let myDownload = document.querySelector("#downloadable a");
	// event listener for when the user clicks (download on click)
	myDownload.addEventListener("click", function(){
	// .setAttribute("download", "any name will do")
    myDownload.setAttribute("download", "name of the file");
});
 
PREVIOUS NEXT
Tagged: #js #setattribute #download
ADD COMMENT
Topic
Name
3+1 =