Jquery 다 중 선택 상자 에서 서로 내용 을 교환 하 는 인 스 턴 스 코드


<head runat="server">
    <title> </title>
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            //
            $('#add').click(function(){
            var options=$('#select1 option:selected');
            var remove=options.remove();
            remove.appendTo("#select2");
            });
            //
            $('#addAll').click(function(){
            var options=$('#select1 option');
            var remove=options.remove();
            remove.appendTo("#select2");
            });
            //
            $('#remove').click(function(){
            var options=$('#select2 option:selected');
            var remove=options.remove();
            remove.appendTo("#select1");
            });
            //
            $('#removeAll').click(function(){
            var options=$('#select2 option');
            var remove=options.remove();
            remove.appendTo("#select1");
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="left">
        <select multiple="multiple" id="select1" style="width:100px;height:160px">
        <option> 1</option>
        <option> 2</option>
        <option> 3</option>
        <option> 4</option>
        <option> 5</option>
        </select>
    </div>
    <div>
        <span id="add"> &gt;&gt;</span><br />
        <span id="addAll"> &gt;&gt;</span>
    </div>
    <div id="right">
        <select multiple="multiple" id="select2" style="width:100px;height:160px"></select>
    </div>
    <div>
        <span id="remove">&lt;&lt; </span><br />
        <span id="removeAll">&lt;&lt; </span>
    </div>
    </form>
</body>

좋은 웹페이지 즐겨찾기