That is, with jQuery, I want to remove the div with an event listener on that div. It seems to work but it gives me that sinking feeling of pulling the rug out from under myself. Here is the fiddle and the code below.
The suggestion that this is a dup question does not apply. I'm not asking just about removing listeners, I'm asking about querying for an element and then removing that element in a conditional of that query.
https://jsfiddle.net/pkellner99/wtkv7f31/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Title</title>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
</head>
<body>
<script type="application/javascript">
$("body").prepend(
`<div id="someguidid">
<img src="https://apod.nasa.gov/apod/image/1904/FairbairnCROSSTOCARINA.jpg"/>
</div>
`
);
$("#someguidid").click(function() {
$("#someguidid").remove("#someguidid");
});
</script>
</body>
</html>