Iam在asp.net中使用jquery如何獲得jQuery中的動態跨度ID?
我有一個用戶控件,其中我有div和div表和tr表tr,tr tr和td我有lables。
ASCX:
<div ID="Container" runat="server" class="dvContainer">
<table ID="Table" class = "Tablecs">
<thead><tr>
<td colspan="2">
<asp:Label ID="lbl1" Text="Swiss" runat="server" /></td>
</tr>
</thead>
<tr>
<td>ABC</td>
<td>DEF</td>
</tr>
<tr>
<td><asp:Label ID="lblPA" Text="SUN 12/21 05:04" runat="server" /></td>
<td ><asp:Label ID="lblPD" Text="SUN 12/21 19:00" runat="server" /></td>
</tr>
<tr>
<td><asp:Label ID="lblAA" Text="SUN 12/21 05:04" runat="server" /></td>
<td ><asp:Label ID="lblAD" Text="SUN 12/21 19:00" runat="server" /></td>
</tr>
</table>
我想要動態地將數據綁定到這些用戶控制。即將數據綁定到用戶控件中的標籤。
我的Jquery
$div.find(".Table").text(oPorts[iCount].Name); // my result is an array of oPorts and i have filed as Name
但這不是工作的罰款。 當我檢查到動態代碼它爲每個標籤生成SPAN 如何在循環中找到SPAN ID dynamiccaly並將數據綁定到標籤?
任何幫助表示讚賞。提前致謝。
如果您有任何獨特這是一個從數據庫返回,將它添加到您的跨度的id屬性。 – Manoj
但我沒有任何跨度在我的頁面,我應該創建任何tr或td的一個跨度? –
asp:標籤被渲染爲跨度。您在usercontrol中的所有元素(包括標籤)都是runat =「server」,這意味着它們的id將在運行時修改。當你運行你的頁面時,轉到viewsource並尋找分配給你的標籤的id模式,即跨度,即ucId_ctrl_lblPA_1,ucId_ctrl_lblPA_2,然後你可以通過這樣的標識循環 –