bootstrap-动态表单
来源:互联网 发布:盘锦兼职淘宝客服招聘 编辑:程序博客网 时间:2024/06/08 19:29
二话不说,直接上代码
- html部分
<!-- The template for adding new field --> <div class="form-group hide" id="bookTemplate"> <label class="col-sm-3 control-label">承包商</label> <div class="col-sm-2"> <form:input path="names" cssClass="form-control" name="names" placeholder="名称"/> </div> <div class="col-sm-2"> <form:input path="merchantIds" cssClass="form-control" name="merchantIds" placeholder="ID"/> </div> <div class="col-sm-2"> <button type="button" class="btn btn-default removeButton"><i class="fa fa-minus"></i> </button> </div> </div>
- js部分
<script src="${context}/plugins/datatables/jquery.dataTables.min.js"></script> <script src="${context}/plugins/datatables/dataTables.bootstrap.min.js"></script> <script src="${context}/plugins/datatables/dataTables.bootstrap.js"></script> <script src="${context}/js/public.js"></script> <script> $(document).ready(function () { var index = 0; $('#form') // Add button click handler .on('click', '.addButton', function () { if (this.name > 0 && index == 0) { index = this.name; } index++; var $template = $('#bookTemplate'), $clone = $template .clone() .removeClass('hide') .removeAttr('id') .attr('data-book-index', index) .insertBefore($template); // Update the name attributes $clone .find('[name="names"]').attr('path', 'contractor[' + index + '].names').attr('name', 'contractor[' + index + '].names').end() .find('[name="merchantIds"]').attr('path', 'contractor[' + index + '].merchantIds').attr('name', 'contractor[' + index + '].merchantIds').end(); // Add new fields // Note that we also pass the validator rules for new field as the third parameter }) // Remove button click handler .on('click', '.removeButton', function () { var $row = $(this).parents('.form-group'), index = $row.attr('data-book-index'); // Remove fields // Remove element containing the fields $row.remove(); });</script>
- 效果图
阅读全文
1 0
- bootstrap-动态表单
- Bootstrap 表单验证formValidation 之表单动态验证
- bootstrap表单
- bootstrap表单
- Bootstrap 表单
- Bootstrap表单
- bootstrap表单
- BootStrap表单
- Bootstrap 表单
- bootstrap表单
- bootstrap表单
- Bootstrap 表单
- Bootstrap 表单
- Bootstrap表单
- bootstrap表单
- Bootstrap表单
- Bootstrap<表单>
- Bootstrap 表单
- SpringAOP
- nginx 编译安装
- (0002) H5开发之Frame框架理解
- 商业智能
- Redhat5.9安装qt5.5.1出错error while loading shared libraries:libX11-cxb.so.1
- bootstrap-动态表单
- linux驱动编写过程中遇到的几个问题及解决办法
- C++ 查找算法-有序集合
- thinkphp3.2源码 ----- 自动加载
- Oracle知识总结之——常用字符串函数
- [bigdata-087] ubuntu 16.04+linux+go 安装 编译 开发 beego+fasthttp web框架
- laravel excel循环导出
- Razor HTML Html.Raw() 混合输出陷阱与技巧
- 没有长远的职业规划的教训