Skip to content

Instantly share code, notes, and snippets.

@mikeulkeul
mikeulkeul / convert_html_table_to_csv
Last active November 30, 2015 02:37
Convert an HTML table to a CSV file that is download directly by the client
function createCSV(selector){
var contentString = "",
$row = document.querySelectorAll(selector),
$els, i,j, l,m, tmp;
for(i=0, l=$row.length; i<l; i++){
$els = $row[i].children;
tmp = [];
for(j=0, m=$els.length; j<m; j++){
tmp.push($els[j].innerText);