动态新增和删除元素

<div id="appendDevelopmentNumber">

</div>

//添加

function addDevelopmentNumber() {

    $("#appendDevelopmentNumber").append('<div class="row"> ' +

        '                        <div class="form-group"> ' +

        '                            <label class="col-sm-4 control-label"></label> ' +

        '                            <input name="developmentNumber" data-role="maskedtextbox" type="text" style="100px;" ' +

        '                                   data-bind="value:model.developmentNumber"  class="k-textbox"/> ' +

        '                            <input name="developmentNumber" data-role="maskedtextbox" type="text" style="180px;" ' +

        '                                   data-bind="value:model.developmentNumber"  class="k-textbox"/> ' +

        '                            <button type="button" class="btn btn-default" aria-label="Left Align" onclick="addDevelopmentNumber()"> ' +

        '                                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> ' +

        '                            </button> ' +

        '                            <button type="button" class="btn btn-default" aria-label="Left Align" onclick="delDevelopmentNumber(this)"> ' +

        '                                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> ' +

        '                            </button> ' +

        '                        </div> ' +

        '                    </div>');

}

//移除

function delDevelopmentNumber(e) {

    console.info(e);

    console.info($(e).parent().parent());

    $(e).parent().parent().remove();

}
---------------------
作者:小发明家啦啦啦啦啦
来源:CSDN
原文:https://blog.csdn.net/qq_39404935/article/details/83000014
版权声明:本文为博主原创文章,转载请附上博文链接!

原文地址:https://www.cnblogs.com/brady-wang/p/11132149.html