I am facing an issue with retrieving the value of a span (or label) from my HTML code. Here is the snippet:
<asp:Repeater ID="rpt_district" runat="server" >
<ItemTemplate>
<tbody id='bodies'>
<tr>
<td>
<span id="district_id"><%# Eval("DISTRICT_ID") %></span>
</td>
<td><%# Eval("DISTRICT_NAME") %></td>
<td>
<asp:Label ID="lb_city_id" runat="server" Text='<%# Eval("CITY_ID") %>'></asp:Label>
</td>
<td style="float:left; margin-left:5px;">
<asp:CheckBox ID="cb_status" runat="server" onclick="javascript: return false;" />
<asp:HiddenField ID="hf_status" Value='<%# Eval("ENABLE") %>' runat="server" />
</td>
<td>
<div style="float:left; margin-left:4px;" >
<asp:ImageButton ID="ib_edit" runat="server" ImageUrl="~/Hinh/icons/Edit.png" ToolTip="Edit" />
</div>
<div style="float:left; margin-left:4px;">
<asp:ImageButton ID="ib_delete" runat="server" ImageUrl="~/Hinh/icons/Trash.png"
ToolTip="Delete" CommandArgument='<%# Eval("DISTRICT_ID") %>'
OnClientClick="getvalue(); return false;"/>
</div>
</td>
</tr>
</tbody>
</ItemTemplate>
</asp:Repeater>
I need to extract the value of district_id in the span tag (or label) using JavaScript when clicking on the image button.
function getvalue() {
var thisspan = $('.district_id').eq(0);
alert(thisspan);
}
However, I am only able to retrieve the value in the first column because of eq(0). I aim to achieve this using JavaScript or jQuery and not through code-behind. Thank you for your assistance.