我可以使用 jQuery 向用户控件中的文本框添加值。下面是我的代码:
$("input[id*=txtApproverEmail]").val("EmailAddress");
如何使用 jQuery 或 JavaScript 向用户控件中的列表框添加或追加值?
下面是我的用户控件:
<tr>
<td>Select Approver:</td>
<td>
<asp:TextBox ID="txtApproverEmail" runat="server" CssClass="text ui-widget-content ui-corner-all" ReadOnly="true"></asp:TextBox>
<img id="imgCOApproverEmail" src="../Images/Binoculars.png" />
</td>
</tr>
<tr>
<td>Carbon Copy To:</td>
<td>
<asp:ListBox ID="lstCCTo" runat="server" CssClass="text ui-widget-content ui-corner-all" Width="310px"></asp:ListBox>
<img id="imgCOApproverEmailCCTo" src="../Images/Binoculars.png" />
</td>
</tr>
最佳答案
试试这个:
$('select').append('<option>New value</option>');
或者
$('select[id*=lstCCTo]').append('<option>New value</option>');
关于javascript - 使用 Javascript 或 Jquery 将值添加到用户控件中的列表框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24061277/