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

297
Views
jQuery: Unable to remove unwanted elements and getting remaining HTML

I am fetching URL content via Ajax. In the text, I have to find the tag containing "See Additional", if found, mark all HTML after it with a certain class, for instance .REMOVE. I am unable to extract the irrelevant DOM but I am unable disassociate with the rest of the HTML. I also tried remove() but I am unable to fetch the remaining HTML. Below is my code:

$( document ).ready(function() {
  $.get("http://localhost:8000/read.php", function(data, status){
      html = $.parseHTML( data ) // Construct DOM from string
      //Check if it exist, remove/isolate it
      see_additional = $(html).find("H2:contains('See Additional')");
      if(see_additional.length > 0) {
        console.log('Found it')
        parent = see_additional.parent()
        $(parent).addClass('remove')
        //parent.remove();
        //console.log(parent.html())
        $('#view').html($(html).html()) // The HTML here is NOT showing entire HTML without removed parent DOM
      }
    });
  });

End Goal

Basically, I have to count the number of links on a page but it should ignore links that are found in HTML after H1/H2 Tags contain "See Additional.."

about 4 years ago · Juan Pablo Isaza
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!