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

310
Vistas
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
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