Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Is it possible to take a JS var representing an element that has been appended to multiple places, and delete it using the var?

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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/.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!