0
How to convert and display a table data into json object onclick of a button.
I HV a table which has few rows and 3 cols. I want to read the table data on click of a button and save it into Jason format. how can I acheive it. using jQuery or JavaScript.
1 Antwort
0
var lines = $("table tr");
var json = {};
jQuery.each(lines, function(key){
var l = {};
var cols = $(this).find("td");
jQuery.each(cols, function(key, val){
l[key]=val.innerHTML;
});
json[key]=l;
})
json = JSON.stringify(json);
document.body.append(json);