Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tableToJson(table) {
- var data = [];
- for (var i=0; i<table.rows.length; i++) {
- var tableRow = table.rows[i];
- var rowData = [];
- for (var j=0; j<tableRow.cells.length; j++) {
- rowData.push(tableRow.cells[j].innerText);;
- }
- data.push(rowData);
- }
- return data;
- }
- var table = document.querySelector("tbody")
- var json = tableToJson(table)
- console.log(JSON.stringify(json))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement