Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

308
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda