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.