See this fiddle. I have an info var that I can easily append to 2 places. But I'd like to also easily remove it from both places without doing something more complicated like $("p").remove()
I know this seems super not complicated, but in production it's harder. I'm always working with the info var so it'd be great if there was some way to say info.removeInAllInstances() or something
I'm not a master in JQuery, but apparentely remove() removes all instances of something. You could filter by an specific class and remove the paragraphs.
Look this example:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>remove demo</title>
<style>
p {
background: yellow;
margin: 6px 0;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<p>Hello</p>
how are
<p>you?</p>
<button>Call remove() on paragraphs</button>
<script>
$( "button" ).click(function() {
$( "p" ).remove();
});
</script>
</body>
</html>
I get it on https://api.jquery.com/remove/.