zoukankan      html  css  js  c++  java
  • jQuery下拉框操作系列$("option:selected",this) &&(锋利的jQuery)

    jQuery下拉框操作系列$("option:selected",this)  &&(锋利的jQuery)

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>下拉框应用</title>
        <script src="../../js/jquery-1.4.4.min.js"></script>
    </head>
    <body>
        <div class="centent">
            <select multiple id="select1" style="100px; height:160px;">
                <option value="1">选项1</option>
                <option value="2">选项2</option>
                <option value="3">选项3</option>
                <option value="4">选项4</option>
                <option value="5">选项5</option>
                <option value="6">选项6</option>
                <option value="7">选项7</option>
                <option value="8">选项8</option>
            </select>
            <div>
                <span id="add">选中添加到右边≥≥</span>
                <span id="add_all">全部添加到右边≥≥</span>
            </div>
        </div>
        <div class="centent">
            <select multiple id="select2" style="100px; height:160px;"></select>
            <div>
                <span id="remove">选中删除到左边<<</span>
                <span id="remove_all">全部删除到左边<<</span>
            </div>
        </div>
        <script>
            $(function () {
                $("#add").click(function () {
                    var $options = $("#select1 option:selected");  //获取选中的选项
                    //var $remove = $options.remove();  //删除下拉列表中选中的选项
                    $options.appendTo("#select2");   //追加到select2
                })
    
                $("#add_all").click(function () {
                    var $options = $("#select1 option");  //获取选中的选项
                    //var $remove = $options.remove();  //删除下拉列表中选中的选项
                    $options.appendTo("#select2");   //追加到select2
                })
    
                $("#select1").dblclick(function () {
                    var $options = $("option:selected", this);  //获取选中的选项
                    //var $remove = $options.remove();  //删除下拉列表中选中的选项
                    $options.appendTo("#select2");   //追加到select2
                })
    
                $("#remove").click(function () {
                    var $options = $("#select2 option:selected");  //获取选中的选项
                    //var $remove = $options.remove();  //删除下拉列表中选中的选项
                    $options.appendTo("#select1");   //追加到select2
                })
    
                $("#remove_all").click(function () {
                    var $options = $("#select2 option");  //获取选中的选项
                    //var $remove = $options.remove();  //删除下拉列表中选中的选项
                    $options.appendTo("#select1");   //追加到select2
                })
    
                $("#select2").dblclick(function () {
                    var $options = $("option:selected", this);  //获取选中的选项
                    //var $remove = $options.remove();  //删除下拉列表中选中的选项
                    $options.appendTo("#select1");   //追加到select2
                })
    
            })
        </script>
    </body>
    </html>
    

      

    生命中最值得欣慰的,莫过于一觉醒来,你还在身旁
  • 相关阅读:
    ArcGIS Engine 常用方法(转)
    正则表达式 C#System.Text.RegularExpressions.Regex
    ae中栅格数据转为矢量数据 (转)
    ArcEngine 渲染的使用 (转)
    C#字符串分割成数组,中间多空格
    <C++ GUI Programming with Qt4 ,Second Edition> 学习笔记
    perl module and its package
    static_cast reinterpret_cast
    阅读<inside the c++ object modle > 有感
    C++ virtual table
  • 原文地址:https://www.cnblogs.com/chaonuanxi/p/10336297.html
Copyright © 2011-2022 走看看