I had a thread sometime back thanks to @James_Hibbard we managed to remove all hrefs from a linksContainer. What I 'd like now is to extend this function so we can remove any strings that match a certain value.
Here is a demo of the existing function which I’d like to extend, displayed below.
$("div.linksContainer").find("a").each(function(){
var linkText = $(this).text();
$(this).before(linkText);
$(this).remove();
});
The strings I’m trying to remove are in the same linksContainer, wondering how we can add something like:
Ok, as things stand with the function, all < a > are removed, some of these < a > have certain strings as their anchor text. So, if the anchor text matches val = ‘example…’ remove them but leave all other anchor text as is.
Does that make sense?
Example, with the jsfiddle example, if we can remove the string example1. Though example1 will have /9834834 so we need to detect not only example1 but example1/random-value
Kind of. I still want to remove all links as before, though the ones that have a matching url I’d also like to remove the string, not just the link. So while we check for links to remove, if any of these links have a matching string, remove everything.
Update
Just one issue, some of these links are wrapped inside another element < p > is it possible to remove the container aswell?
Updated demo show what I mean.