zoukankan      html  css  js  c++  java
  • jQuery--加一行减一行


    效果:



    知识点:

    克隆--clone()

    追加--append()

    移除--remove()

    代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <div id="search_conditions">
        <div class="condition">
            <a onclick="AddCondition(this,'#search_conditions')">+</a>
            <input />
        </div>
    </div>
     
    <script src="../js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" >
        function AddCondition(ths,container){
            //克隆condition整个div
            //再把克隆的div追加到search_conditions下面
            var cp = $(ths).parent().clone();
            cp.children(':first').text('-').attr('onclick','RemoveCondition(this,"#search_conditions")');
            $(container).append(cp);
    //            cp.appendTo(container)
        }
        function RemoveCondition(ths,container){
            $(ths).parent().remove();
        }
    </script>

    本段代码效果:


    链接:​

    视频:D16--jQuery文档处理

    课件:cmdb_plugin/demo_2.html






  • 相关阅读:
    VUE 入门基础(2)
    VUE 入门基础(1)
    常用正则表达式
    git 常用命令
    JavaScript 常用算法
    SVG 使用
    移动前端头部标签(HTML5 meta)
    开发常用小demo 整理
    Reactjs 入门基础(三)
    Reactjs 入门基础(二)
  • 原文地址:https://www.cnblogs.com/daliangtou/p/5236375.html
Copyright © 2011-2022 走看看