jquery listbox左右移动 并且取值

<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(
function(){
$(
"#left").click(function(){
var movevalue = $("#ListBox1 option:selected").val();
$(
"#ListBox2").append("<option>"+movevalue+"</option>");
$(
"#ListBox1 option:selected").remove();
})
$(
"#right").click(function(){
var movevalue = $("#ListBox2 option:selected").val();
$(
"#ListBox1").append("<option>"+movevalue+"</option>");
$(
"#ListBox2 option:selected").remove();
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ListBox ID="ListBox1" runat="server" Width="100" Height="200">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:ListBox>
<a id="left">向左</a>
<a id="right">向右</a>
<asp:ListBox ID="ListBox2" runat="server" Width="100" Height="200">
</asp:ListBox>
</form>
</body>

 

你可能感兴趣的:(listbox)