I have a table where the first two cells are inputfields, and I'm trying to map all of the table data inside an array. But I don't know how to get the data from the input fields right know it only maps the the other data.
<table width="100%">
<thead>
<tr>
<td><strong>Amount</strong></td>
<td><strong>Price</strong></td>
<td><strong>Articleid</strong></td>
<td><strong>Descr</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td><input class="amount" type="text" value="1"></td>
<td><input class="purchprice" type="text" value="2.00"></td>
<td>210003</td>
<td>Example_1</td>
</tr>
<tr>
<td><input class="amount" type="text" value="1"></td>
<td><input class="purchprice" type="text" value="19.25"></td>
<td>128025</td>
<td>Example_2</td>
</tr>
<tr>
<td><input class="amount" type="text" value="3"></td>
<td><input class="purchprice" type="text" value="23.45"></td>
<td>124005</td>
<td>Example_3</td>
</tr>
</tbody>
</table>
jQuery
<button type="button" class="map">Map table</button>
$('.map').on('click', function() {
var tableData = $('table tbody td').map(function() {
return $(this).text();
}).get();
console.log($.trim(tableData[0]));
console.log($.trim(tableData[1]));
console.log($.trim(tableData[2]));
console.log($.trim(tableData[3]));
});
return $(this).is(':has(:input)')?$(':input',this).val():$(this).text();