JQuery get table row values from input and save to array
16,296
$('#button').click(function () {
var array = [];
$('#table tr').each(function () {
var values = [];
$(this)
.find('input')
.each(function () {
values.push(this.val());
});
array.push(values);
});
});
then you can take items by array.pop();
Related videos on Youtube
Author by
DehMotth
Updated on June 04, 2022Comments
-
DehMotth almost 2 years
I have a table with input fields inside the td. How can i get the values from the input fields (by button click) and store them into an array (one row) using JQuery ? So there are different rows with different contexts and i would like to process row by row, so i have to identify those rows by class and so on.
Thanks!
Update: I would like to have values from
test1
in an array,test2
in an array and so on.<tr class="test1"> <td> <input type="text" name="test"> <input type="text" name="test"> <input type="text" name="test"> </td> </tr> <tr class="test2"> <td> <input type="text" name="test"> <input type="text" name="test"> <input type="text" name="test"> </td> </tr>
-
Shah Rukh almost 10 yearsCan you place code ? or any effort u did ?
-
skparwal almost 10 yearsCan you paste your code to understand better? and easily we can help you in this regard.
-
DehMotth almost 10 yearsUpdated question, thanks!
-