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

323
Views
Jquery: How to ignore/remove all element irrespective of their level after certain text?

So I have a page like this. I have to check element which contains "See Additional". I have done this. Now all I have to do to remove all HTML after it. I know jqeuery provides .nextall() but it is for elements at same level. What should I do to remove elements irrespective of their levels. Below is my code:

$( document ).ready(function() {
  $.get("http://localhost:8000/read.php", function(data, status){
    
    // var data = '<h1>Hi World</h1';
    var html = '<div id="rendered">'+data+'</div>';
    
      
      //Check if it exist, it should be marked out as irrelevant
      see_additional = $(html).find("H2:contains('See Additional')");
      
      if(see_additional.length > 0) {
        console.log('Found it')
        parent = see_additional.parent()
        $(see_additional).addClass("intro") // not working
        console.log(parent.attr('id'))
        //$(parent).addClass('remove')
        // parent.remove();
        //console.log(parent.html())        
        $('#view').html($(html).filter('#rendered').html()) // html viewer
      }
    });
  });

Please note this page is one of the examples. It could be any page that contains "See Additional". The reason to do this is that I have to ignore all links if they are found in elements AFTER the element contains "See Additional". One way is to remove but I am not successful in it yet.

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!