Given this html markup
<tr>
<td class="tdDescCell"><b><i>Product Savings: </i></b></td>
<td class="tdDescCell"><b><i> <asp:Label ID="lblEBSavings_Q1" Text="" cssClass="labelValueCalc" runat="server" ClientIDMode="Static"></asp:Label></i></b></td>
<td class="tdDescCell"><b><i> <asp:Label ID="lblEBSavings_Q2" Text="" cssClass="labelValueCalc" runat="server" ClientIDMode="Static"></asp:Label></i></b></td>
<td class="tdDescCell"><b><i> <asp:Label ID="lblEBSavings_Q3" Text="" cssClass="labelValueCalc" runat="server" ClientIDMode="Static"></asp:Label></i></b></td>
<td class="tdDescCell"><b><i> <asp:Label ID="lblEBSavings_Q4" Text="" cssClass="labelValueCalc" runat="server" ClientIDMode="Static"></asp:Label></i></b></td>
</tr>
Which renders like
<tr>
<td class="tdDescCell"><b><i>Product Savings: </i></b></td>
<td class="tdDescCell"><b><i> <span id="lblEBSavings_Q1" class="labelValueCalc"></span></i></b></td>
<td class="tdDescCell"><b><i> <span id="lblEBSavings_Q2" class="labelValueCalc"></span></i></b></td>
<td class="tdDescCell"><b><i> <span id="lblEBSavings_Q3" class="labelValueCalc"></span></i></b></td>
<td class="tdDescCell"><b><i> <span id="lblEBSavings_Q4" class="labelValueCalc"></span></i></b></td>
</tr>
I use the following jquery to set the labels text, which seems quite redundant and sloppy.
$("#lblEBSavings_Q1").text("$" + ebSavingsQtrly.toString());
$("#lblEBSavings_Q2").text("$" + ebSavingsQtrly.toString());
$("#lblEBSavings_Q3").text("$" + ebSavingsQtrly.toString());
$("#lblEBSavings_Q4").text("$" + ebSavingsQtrly.toString());
I tried to refactor using each and contains like the following line,
$("#fld_ROICalcOutput > span").contains("lblEBSavings").each().text("$" + ebSavingsQtrly.toString());
Where #fld_ROICalcOutput is the parent fieldset element of the table. Where am I going wrong here and is there a better way to express what I am trying to accomplish here.