I'm working on a project where I have to delete en element in a certain condition (if). My code generates a <li>
in which data is inserted via an array. I need to delete that <li>
if some conditions are met.
Since removeParent()
doesn't exist I've found different methods saying to use
e.parentNode.parentNode.removeChild(e.parentNode);
Rings a bell, it works in certains cases of course.
BUT
In my case, this is dynamically rendered elements in an array inside the <li>
and there is no parent of the parent, so I get an error.
My script looks for an element in the <li>
, in my test I use a <div>
found by its class.
$(node).find('.results-name')[0].parentNode.remove();
Does NOT work unfortunately so I'm looking for other ideas...
Any clue? Thanks a lot!