我有以下代码,但我指定为cnt
的计数器不起作用,因为我正在添加越来越多的代码块,它不会增加表单名称
这是我的代码
var cnt = 1;
$(".addMore").click(function() {
cnt++;
$(".append-outer").append('<div class="append-inner">\
<div>\
<div class="col-sm-8">\
<div class="form-group">\
<label>Company</label>\
<input type="text" name="form_company"'+cnt+'" class="form-control" _required="required">\
</div>\
</div>\
<div class="col-sm-4">\
<div class="form-group">\
<label>Phone</label>\
<input type="text" name="form_phone"'+cnt+'" class="form-control" _required="required">\
</div>\
</div>\
<div class="clearfix"></div>\
</div>\
<div>\
<div class="col-sm-8">\
<div class="form-group">\
<label>Address</label>\
<input type="text" name="form_address"'+cnt+'" class="form-control" _required="required">\
</div>\
</div>\
<div class="col-sm-4">\
<div class="form-group">\
<label>FAX</label>\
<input type="text" name="form_fax"'+cnt+'" class="form-control" _required="required">\
</div>\
</div>\
<div class="clearfix"></div>\
</div>\
<div>\
<div class="col-sm-6">\
<div class="form-group">\
<label>Contact</label>\
<input type="text" name="form_contact"'+cnt+'" class="form-control" _required="required">\
</div>\
</div>\
<div class="col-sm-6">\
<div class="form-group">\
<label>Account</label>\
<input type="text" name="form_account"'+cnt+'" class="form-control" _required="required">\
</div>\
</div>\
<div class="clearfix"></div>\
</div>\
<button type="button" class="remove-append"><i class="fa fa-trash-o" aria-hidden="true"></i></button>\
</div>');
});