JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<thead>
<tr>
<th>Cats</th>
<th>Dogs</th>
<th>Birds</th>
<th>Fish</th>
</tr>
</thead>
<tbody>
<tr>
<td>Persian</td>
<td>Husky</td>
<td>Canary</td>
<td>Guppy</td>
</tr>
<tr id="secondRow">
<td>Siamese</td>
<td>Pug</td>
<td>Parakeet</td>
<td>Clownfish</td>
</tr>
<tr>
<td>Maine coon</td>
<td>Labrador</td>
<td>Cockatiel</td>
<td>Goldfish</td>
</tr>
</tbody>
</table>
<button>Grab all items in 2nd row and convert to array</button>
<p></p>
CSS
table {
margin: 20px 0;
}
table, td {
border: 1px solid #c0c0c0;
}
td {
padding: 3px 7px;
}
#secondRow td {
background-color: #f1f1f1;
}
JavaScript
$('button').click(function() {
var pets = [];
$('#secondRow td').each(function(i, elem) {
pets.push($(elem).text());
});
console.log(pets);
$('p').html('Your array contains: <strong>' + pets + '</strong>');
});