question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parent element not being removed when removing image

See original GitHub issue

In callbacks, onImageUpload I create a block <picture><img></picture>.

Also in the callbacks, I’ve added:

onMediaDelete: function(target) {       
   target.closest('picture').remove();
}

But the parent <picture> is not removed. I console-logged the properties of target and both parentElement and parentNode are null.

How can I delete the entire <picture><img></picture> block onMediaDelete?

Thank you in advance.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
1der1commented, Jun 9, 2022

Then use $(".note-editable") instead.

1reaction
pcristovcommented, Jun 9, 2022

Appreciate it @1der1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delete parent element and all children if img src broken
I'm doing an Ajax query that pulls back a JSON array filled with ~50 urls to images. I then use a forEach on...
Read more >
jQuery: Remove parent element containing empty span | WP-Mix
This technique is useful in any scenario where you want to remove not just an empty span or div, but also the parent...
Read more >
How to remove a parent div in JavaScript if all the ids ... - Quora
The easiest way would be to get the parent element and simply use the remove() method on it: document.getElementById("element-id").remove();. or the ...
Read more >
.contents() | jQuery API Documentation
Given a jQuery object that represents a set of DOM elements, ... Stop the currently-running animation, remove all queued animations, ... :image Selector....
Read more >
How to delete data from child and also its image ... - MongoDB
I used MongoDB middleware remove to perform cascade dele… ... deleting it but if I delete the parent the child is deleted but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found