I have an HTML table and I want to iterate through its rows and create a collection or lets say an \"array of objects\".
For example:
It's a bit tricky based on the given structure. You may have to modify the HTML a bit to map cells to headers, like below.
var myArray = [];
$("#tbPermission").find("td").each(function() {
var $this = $(this), obj = {};
obj[$this.data("column")] = $this.text();
myArray.push(obj);
});
alert ( JSON.stringify(myArray) );
User ID
User Name
1
Test1
Please give in some time to learn about Array.push() and Objects in Javascript. Hope that helps.