Created
March 14, 2019 20:04
-
-
Save jasp402/a3b5f3d33b7b9e654174b04cd11ea0ab to your computer and use it in GitHub Desktop.
JavaScript - Get text of table to convert in Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tblhdr = $('#folder_list_218 th').map(function () { | |
return $(this).text(); | |
}).get(); | |
console.log(tblhdr); | |
var tbl = $('#folder_list_218 tbody tr').map(function(idx, el) { | |
var td = $(el).find('td'); | |
var obj = {id: idx+1}; | |
for (var i = 0; i < tblhdr.length; i++) { | |
obj[tblhdr[i]] = td.eq(i).text(); | |
} | |
return obj; | |
}).get(); | |
console.log(tbl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment