I have a table where the last two <td>
tags in each row have text inputs. I am trying to dump the table into an array to then make a csv.
Code that converts table to array:
$("table#results-table tr").each(function() {
var arrayOfThisRow = [];
var tableData = $(this).find('td');
if (tableData.length > 0) {
tableData.each(function() {
arrayOfThisRow.push($(this).text());
});
tableArray.push(arrayOfThisRow);
}
});
this will return the items with just text, but not the data in the inputs. I assume this has to do with the $(this).text()
but I cannot figure out how to fix it.
If the input
is inside td
and if there is only 1 input
inside that td
then
$(this).find('input').val()
will get you the values from input field
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.