I'm trying to build and array with the values of the table row that the user clicks.
so right now I have all of this inside a
$('#myDiv').find('tr').click(function(){
and assign variables to columns in the table on the row the user clicks
var firstName = $(this).find('td:nth-child(1)').text();
var middleName = $(this).find('td:nth-child(2)').text();
var lastName = $(this).find('td:nth-child(3)').text();
so now I'm trying to put those in an array
var userRow = [];
userRow['firstName'] = firstName;
userRow['middleName'] = middleName;
userRow['lastName'] = lastName;
so the thing is, the user is able to click on multiple table rows. When the click a row it toggles a class 'highlight' in the row (which changes the background color of the row)
I'm stuck on creating a loop so that all of the rows they click get added into another array. Kind of like this-
Array1 {
userRow {
'firstName' = ...;
ect...
}
}
so when I reference Array1 it'll show me all of the information that I've grabbed from all of the rows with the 'highlight' class, which I've put in the array 'userRow'
I've read on javascript arrays, but like I said I'm stuck and could use some help. It is much appreciated, thank you.
EDIT: I'm leaving right now, I will be back on tomorrow to choose an answer. thanks all of you for helping me understand this