javascript - Create a new object array based on jQuery result set -
i have table contains list of people. want query table , produce new array of objects pass ajax call.
so far have this:
var result = $("table tr").not(":has(th)").each(function() { return { id: 0, islead: 0 }; });
assuming table 3 rows, expected value result
be:
[{ id: 0, islead: 0 }, { id: 0, islead: 0 }, { id: 0, islead: 0 }]
instead, result
contains elements match jquery selector.
i'll providing proper values id
, islead
based on data in row, keep things simple i've excluded here.
i'm missing fundamental in approach. i've tried searching existing questions maybe i'm not phrasing correctly can't find else similar this.
sounds want map
, not each
var result = $("table tr").not(":has(th)").map(function() { return { id: 0, islead: 0 }; }).get();
Comments
Post a Comment