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

296
Views
jQuery: no se pueden eliminar elementos no deseados y obtener el HTML restante

Estoy obteniendo contenido de URL a través de Ajax. En el texto, tengo que encontrar la etiqueta que contiene "Ver adicional", si la encuentra, marque todo el HTML después de ella con una determinada clase, por ejemplo, .REMOVE . No puedo extraer el DOM irrelevante pero no puedo desasociarlo con el resto del HTML. También intenté remove() pero no puedo obtener el HTML restante. A continuación se muestra mi código:

 $( 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 } }); });

Objetivo final

Básicamente, tengo que contar la cantidad de enlaces en una página, pero debería ignorar los enlaces que se encuentran en HTML después de que las etiquetas H1/H2 contengan "Ver adicional...".

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!