I have a table
<table id='mytable'>
<tr>
<th> Cars </th>
<th> Food </th>
<th> clothes</th>
</tr>
<tr>
<td> 1 </td>
<td> yes </td>
<td> jeans </td>
</tr>
<tr>
<td> 1 </td>
<td> yes </td>
<td> jeans </td>
</tr>
<tr>
<td> 84 </td>
<td> no </td>
<td> shirt </td>
</tr>
<tr>
<td> 4984 </td>
<td> yes </td>
<td> hat </td>
</tr>
I have a javascript function that takes the first td and get the value, but it only takes the first value in this case 1. I want to take all of the first columns distinct values and store it in an array. so the end result should be
$firstColumnArray = [1,84, 4984]
My function looks like
$(document).ready(function()
{
$one = document.getElementById("table");
$two = $(this).find("td").eq(0).text()
alert($two);
});
How can i loop though the entire contents of the tables first row and store it in a variable?