<button class="layui-btn btnAddtr">增加条件</button>
<div id="specifDiv">
</div>
//添加操作
$(".btnAddtr").click(function(){
//定义增加的部分
var html = "<div class=\"layui-form-item\">\n" +
" <label class=\"layui-form-label\">字段</label>\n" +
" <div class=\"layui-input-block\">\n" +
" <select name=\"processFieldId\" id=\"processFieldId\">\n" +
" <option value=\"\">请选择</option>\n" +
" <option th:value=\"1\">是</option>\n" +
" <option th:value=\"2\">否</option>\n" +
" </select>\n" +
" </div>\n" +
" </div>\n";
//获取原来DIV内容
var oldHtml = document.getElementById("specifDiv").innerHTML;
//拼接数据
var newHtml = oldHtml + html;
//清空原来的内容
document.getElementById("specifDiv").innerHTML="";
//增加新内容
document.getElementById("specifDiv").innerHTML=newHtml;
//刷新select
form.render("select");
});
来源:oschina
链接:https://my.oschina.net/u/3204029/blog/4271669