0
I am facing problems to clone elements with javascript.
The problem:
As shown below, the form contains a checkbox that when clicking executes a function that changes the input value Qtd Min.
By clicking on the text Add Category, creates a clone of the full form;
By clicking on the text Add subcategory, creates a clone of inputs name, description and price. That is, it is a clone within another clone. But when you clone that form the function of checkbox and subclone inputs do not work;
Is there any practical way to do this? I need to create several categories and within each category create several subcategories.
Below the javascript code I’m currently using:
//clone categoria /////////////////////////////////
$(document).ready(function(){
$('#but_addcategoria').click(function(){
var newel = $('.categoria:last')
.clone(true)
.find("input").val("").end()
$(newel).insertAfter(".categoria:last");
});
});
//clone subcategoria
$(document).ready(function(){
$('#but_addsubcategoria').click(function(){
var newel = $('.tb-complementos:last')
.clone(true)
.find("input").val("").end();
$(newel).insertAfter(".tb-complementos:last");
});
});
I am very grateful if friends can help me.
include html in your question, [mcve]
– Leandro Angelo