I've got a table like this:
<table>
<% foreach (var item in Model.Data) { %>
<tr>
<td><a href="#"><div id="stopId"><%: item.StopID %></div></a></td>
...
...
</tr>
</table>
And I'm using this jQuery to select the stop id that the user clicked.
$(function () {
$("#stopId").live('click', function () {
var stopId = $("#stopId").html()
...
...
});
});
Yet my variable stopId always ends up being the first stopId in the table and not the one that was actually clicked. So where am I going wrong?