2
I have the following function
addPerson = function(id, name) {
people[id] = name;
console.log(people[id].parentNode); // Exibe corretamente
console.log(name.parentNode); // Exibe corretamente
name.parentNode.removeChild(name);
console.log(people[id].parentNode); // Deixa de exibir
console.log(name.parentNode); // Deixa de exibir
if(!name.previousElementSibling) {
$(name.parentNode).append(name);
}else{
name.previousElementSibling.insertAfter(name);
}
};
--
The parameter name reference an element in DOM, when the function is called people[id] receives this element, but when executing some example delete element change, the reference loses access to methods, example the parentNode, tried to use the clone of J-query, but it didn’t work.
Is there any way to clone the object, keep the native methods and detach it from the element in the DOM?
So instead of vector you could use a list, I think it would be more viable in your case.
– Dev