Reputation: 1875
var j=0;
var cloneObj='<div class="ui-widget-content"><div class="form_container-'+j+'">
<div class="placeholder">Add your form fields here</div><div style="clear: both;" >
</div></div> </div>';
and cloning as
$('.button_class').click(function(j){
$(cloneObj).clone(false).appendTo('body');
j++;
console.log(j);
});
is not working any solution.?
Upvotes: 0
Views: 77
Reputation: 32591
$('.button_class').click(function () {
var cloneObj = '<div class="ui-widget-content"><div class="form_container-' + j + '"><div class="placeholder">Add your form fields here</div><div style="clear: both;" ></div></div> </div>';
$(cloneObj).appendTo('body');
j++;
console.log(j);
});
You need to put cloneObj inside the click button to increment j
and remove j from function(j)
and you dont need to clone the object just append it
Upvotes: 1
Reputation: 388436
you don't have to use clone here
$('.button_class').click(function(j){
$(cloneObj).appendTo('body');
j++;
console.log(j);
});
Upvotes: 1