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
references an element in DOM
, when the function is called people[id]
it receives this element, however when executing some example deletion of the element, the reference loses access to the methods, eg% , I tried to use parentNode
of clone
, but it did not work.
Is there any way to clone the object, keep the native methods and unlink it from the element in J-query
?