Here is my Html code block I loaded table data from rest api and i want to get array object from each row td data attributes selected using the checkbox
<tr>
<th scope='row' class='product-item-check'><input class='product-item-checkbox' type='checkbox' name='select-product' value='"+obj.pk_productId+"'></th>
<td data-th_name='"+th_cell+"' data-td_name='"+td_cell+"' >" + td_cell + "</td>
</tr>
My Sample Code
$(document).on('click','.product-item-checkbox',function(){
var thName;
var tdName;
var td;
var checkedValue = $('.product-item-checkbox:checked').closest('tr').find('td').map(function(i, v){
thName = $(this).data('th_name');
tdName = $(this).data('td_name');
td = {
"thead":thName,
"tdata":tdName
}
return td;
}).get();
console.log(checkedValue);
});
Current OutPut
Expected Output
[
{
"pk_productId": 1940690,
"productCode": "abcmkk",
"productDescription": "Sample Description",
"callout": 12qwww,
"product_type": "woven",
"product_image": null,
"status": 1234,
},
{
"pk_productId": 1940690,
"productCode": "abcmkk",
"productDescription": "Sample Description",
"callout": 12qwww,
"product_type": "woven",
"product_image": null,
"status": 1234,
}
]