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>

 

posted @ 2013-09-22 17:30  Mr.Leo  阅读(495)  评论(0编辑  收藏  举报