Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

322
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda