I have table that is built dynamically with Razor in MVC.
I want to be able to click on the a row and get the value of lets's say the first column ID.
Right now it's getting all the columns but I don't know too much Javascript or how it's stored with text.
Anyways what I'm looking for is to get a certain column on the row I clicked.
Razor MVC
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>ID</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
@for(int i=0; i<Model.changes.Count(); i++)
{
<tr>
<td>@Model.changes[i].ID</td>
<td>@Model.changes[i].Owner</td>
</tr>
}
</tbody>
</table>
Javascript
<script>
var table = $("#myTable tr");
table.click(function () {
alert($(this).text());
});
</script>