form.on(‘submit(formAddCooperation)’, function (data) {
cooperation += 1;
let html = `<div class=”layui-card” style=”padding-top:1rem;”>
<fieldset class=”layui-elem-field layui-field-title”>
<legend>合作集团[`+cooperation+`]</legend>
</fieldset>
<div class=”layui-card-body”>
<div class=”layui-form-item”>
<label class=”layui-form-label”><span style=”color: red;”>*</span>标题</label>
<div class=”layui-input-block”>
<input type=”text” name=”cooperation[`+cooperation+`][‘title’]” placeholder=”请输入”
autocomplete=”off” class=”layui-input”>
</div>
</div>
<div class=”layui-form-item”>
<label class=”layui-form-label”><span style=”color: red;”>*</span>概要</label>
<div class=”layui-input-block”>
<input type=”text” name=”cooperation[`+cooperation+`][‘subtitle’]” placeholder=”请输入”
autocomplete=”off” class=”layui-input”>
</div>
</div>
<div class=”layui-form-item”>
<label class=”layui-form-label”><span style=”color: red;”>*</span>跳转</label>
<div class=”layui-input-block”>
<input type=”text” name=”cooperation[`+cooperation+`][‘href’]” placeholder=”请输入”
autocomplete=”off” class=”layui-input”>
</div>
</div>
<div class=”layui-form-item”>
<label class=”layui-form-label”><span style=”color: red;”>*</span>图片</label>
<div class=”layui-input-block”>
<div id=”upfilecooperation`+cooperation+`”>
<div id=”buttoncooperation`+cooperation+`”>
<i class=”layui-icon”></i>上传图片
</div>
<div id=”imgboxcooperation`+cooperation+`” style=”text-align:left;display: none;”>
<img style=”width: 300px;height: 300px;” id=”imgcooperation`+cooperation+`” />
<input autocomplete=”off” type=”hidden” name=”cooperation[`+cooperation+`][‘img’]”
id=”imginputcooperation`+cooperation+`” />
</div>
</div>
</div>
</div>
</div>
</div>`;
let strEvalProduct = `$(‘#cooperation’).append(html);
upload.render({
elem: ‘#upfilecooperation`+cooperation+`’
, url: ‘{:url(“imgUploadCon”)}’
, done: function (res) {
//上传完毕回调
$(‘#imgcooperation`+cooperation+`’).attr(‘src’, res.msg);
$(‘#imginputcooperation`+cooperation+`’).val(res.msg);
$(‘#buttoncooperation`+cooperation+`’).hide();
$(‘#imgboxcooperation`+cooperation+`’).show();
}
, error: function () {
//请求异常回调
layer.msg(‘上传失败!’, { icon: 2 })
}
});`;
eval(strEvalProduct);
return false;
});
//删除
$(“#product”).on(“click”,’.del’,function(e){
$(e.currentTarget).parent().remove()
})
声明:
本文采用
BY-NC-SA
协议进行授权,如无注明均为原创,转载请注明转自
一颗大萝北
本文地址: JQ生成的HTML点击删除父级元素
本文地址: JQ生成的HTML点击删除父级元素