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.."