I have the following code:
HTML
<table width="30%" border="0">
<tr>
<td colspan="4" align="center">
<asp:Label ID="Label12" runat="server" CssClass="label" Text="Responsabilidades"></asp:Label>
</td>
</tr>
<tr>
<td colspan="4">
<asp:ListBox ID="lstDisponibles" runat="server" Width="140px"
Height="110px" SelectionMode="Multiple">
<asp:ListItem>s</asp:ListItem>
<asp:ListItem>w</asp:ListItem>
<asp:ListItem>f</asp:ListItem>
</asp:ListBox>
</td>
<td>
<input id="imgAdd" type="image" src="../../images/control_fastforward.png" value="button" />
<br />
<input id="imgRem" type="image" src="../../images/control_rewind.png" value="button" />
</td>
<td>
<asp:ListBox ID="lstUsuario" runat="server" Width="140px" Height="110px" SelectionMode="Multiple">
</asp:ListBox>
</td>
<td></td>
</tr>
</table>
and the jQuery Code:
$(document).ready(function () {
$("#imgAdd").click(function () {
$("#lstDisponibles > option[@selected]").appendTo("#lstUsuario");
});
$("#imgRem").click(function () {
$("#lstUsuario > option[@selected]").appendTo("#lstDisponibles");
});
});
I want to move from lstDisponibles to lstUsuarios but this dont work. I can find any example using asp.net listbox element. I test using html tag but this cannot be useful.
Anyone can please helpme with this.
开发者_运维百科Thanks.
Try changing your selector from:
#lstDisponibles > option[@selected]
to:
#lstDisponibles > option:selected
Add would be:
$("#lstUsuario").append($("#lstDisponibles > option:selected"));
They syntax should be
$("#lstDisponibles > option:selected")
Also be careful that .net isn't changing your IDs.
精彩评论